Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement CircleCI deployment when pushing to develop #101

Merged
merged 33 commits into from
Jan 12, 2021

Conversation

leothomas
Copy link
Contributor

What I did:

Implemented CircleCI deployments to a staging CDK stack off of pushes to deployment. There are 2 main reasons for this feature:

  • A staging backend stack allows us to more easily share "in-progress" features with partners (without having to set them up with a local dev environment)
  • A staging backend stack allows us to test updated deployment procedures and any other aspects of the backend that may act differently between a local environment and the AWS environment (networking, rate limiting, etc). In this case, I enabled lambda deployment package generation through the CDK script (rather than docker commands directly in CircleCI - PR here (closed)), and I want to ensure the deployment goes smoothly by deploying from develop, before merging/deploying to prod.

How I did it:

I added a new step to the deployment script which deploys to a staging CDK stack when pushing to develop.

The lambda deployment package generation had originally been disabled in the CDK script and was being done directly CircleCI, due to the fact that lambda deployment package generation in CDK uses docker and it is not possible to mount docker container volumes in CircleCI, since CircleCI also runs in docker, and according to @CiaranEvans:

Running docker in docker? You're gonna have a bad time

In order to enable the CDK script to use docker when deploying the stack from within CircleCI I switched from a docker image executor to a machine executor, which runs the CI pipeline in a Linux VM rather than a docker container. This gives me full controls of the underlying file system, and allows me to mount the volumes needed when generating the lambda deployment package.

How you can test it:

Merge this PR to develop and watch a new staging stack get created in the NASA Impact AWS account!

Note:
Currently the staging stack fails to create because of a limit of 5 VPC's per region in AWS. us-east-1 has one for the prod stack, one for a stack I stood up to share contrail detections with the dev's at Impact, one for a test stack that used to be used by ESA devs (unclear wether it is still being used or not, I didn't want to delete it, just in case). There are 2 VPC's that don't belong to any Cloudformation stack.

Possible solutions:

  • Delete the test stack if we can confirm it's no longer in use by the folks at ESA
  • Figure out what those two other VPC's are in us-east-1 and delete one if it is not needed
  • Deploy the staging stack to a different region
  • Request a VPC-per-region limit increase from AWS
  • Update the CDK stack to create a VPC if one doesn't already exist, but use an existing one if it exsits.

leothomas and others added 29 commits January 5, 2021 14:26
…ation

Refactor lambda package generation in CDK
…aging

Updated circleCI config to deploy to staging on pushes to develop
@leothomas leothomas requested a review from drewbo January 6, 2021 23:14
Copy link

@ciaransweet ciaransweet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, I think you've just left some debugging statements in... maybe?

I appreciate the direct quote 🤣

On the VPC topic, if one of those VPCs does what you need, you could just set your deployment to go into one of those for now, which is a quick fix!

.circleci/config.yml Outdated Show resolved Hide resolved
.circleci/config.yml Outdated Show resolved Hide resolved
@leothomas leothomas merged commit b6cd21b into develop Jan 12, 2021
@leothomas leothomas deleted the feature/circle-ci-lambda-deployment branch January 12, 2021 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants