exanubes / ask-me-anything

If you want to clarify something, have a question about a video or blog post you're trying to follow or have a completely unrelated problem with AWS, open up an issue and I'll do my best to help you out

Home Page:https://github.com/exanubes/ask-me-anything/issues/new

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

multiple envs ecs ci/cd pipeline

AdrianD94 opened this issue · comments

Hello, I'm trying to build a CI/CD pipeline using AWS CDK for deploying Node.js apps to ECS Fargate. Your blog posts were a solid starting point. What I'm trying to do is deploy multiple environments (dev, qa, prod) with different subdomains (dev.api, qa.api, prod.api), varying task counts per environment, and different database sizes per environment. An updated blog post on this topic would be much appreciated!

Hi Adrian, what you're asking is a parametrisation issue. The easiest way to do this is to switch the hard coded values for environment variables. You can create a .env.[environment] files and create environment variables for the dynamic values. Those would be three separate deployments of the stacks. Keep in mind the id's cannot be the same. The simplest solution is to add the NODE_ENV to the start of each id e.g. new Route53Stack(app, ${NODE_ENV}-route-53, props). You'd want to parametrise the domain in route53, the github branch in code pipeline, the auto scaling in ECS and the VPC cidr. Probably some more things too that I might've forgotten. It's good practice to put to use what you've learned so far. Happy hacking :)

What I like to do is make a separate cdk.out for each env to keep them separated, I do this by specifying the output path in the command e.g., cdk synth -o ./dist/dev/cdk.out.