@fjall/components-infrastructure
v0.96.0
Published
Published fjall infrastructure components and utilities.
Downloads
12,966
Keywords
Readme
Fjall Infrastructure
Published fjall infrastructure components and utilities.
Useful commands
npm run buildcompile typescript to jsnpm run watchwatch for changes and compilenpm run testperform the jest unit testscdk deploydeploy this stack to your default AWS account/regioncdk diffcompare deployed stack with current statecdk synthemits the synthesized CloudFormation template
Building patterns
Common service patterns are built using a Stack class (i.e AwsStack) and use a builder pattern.
Referencing VPC
There are three main ways to reference a VPC
- In the same stack
When a VPC is created in the same stack resources that rely on it will automatically detect it.
new AwsStack(`${id}App`)
.addNetwork(FjallVpc.build(`${id}Vpc`))
.addConstruct(Fargate.build(`${id}Fargate`));- In the same CDK Application but different stack
When a VPC is created in the same application, but you want to use separate stacks, you can directly reference the vpc resource itself. This is easily
retrieved from an awsStack using awsStack.getNetwork().
const vpcStack = new AwsStack(`${id}Network`).addNetwork(
FjallVpc.build(`${id}Vpc`)
);
const newStack = new AwsStack(`${id}Compute`, { dependencies: [vpcStack] })
.addNetwork(vpcStack.getNetwork())
.addConstruct(Fargate.build(`${id}Fargate`));- Different CDK Applications
If your VPC was created in a completely separate CDK Stack it can be imported using it's id and stackName. However this method
requires you explicitly configure your AwsStack with an account and `region.
const env = {
region: "us-east-1",
account: "058430617814"
};
const vpcStack = new AwsStack(`${id}Network`, { ...env }).addNetwork(
FjallVpc.build(`${id}Vpc`)
);
const newStack = new AwsStack(`${id}Compute`, {
...env,
dependencies: [vpcStack]
})
.addNetwork(FjallVpc.import(`${id}Vpc`, `${id}Network`))
.addConstruct(Fargate.build(`${id}Fargate`));Publishing package to npm
Log into your NPM account locally (make sure you have 2fa setup before trying this)
npm login
> Username:
> Password
> Email
> 2FaUpdate the version in ./package.json, build the package and then run publish command
npm run build
npm publish --access restricted