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

Pipeline stack for CI/CD #389

Closed
chriswilty opened this issue Oct 10, 2023 · 3 comments
Closed

Pipeline stack for CI/CD #389

chriswilty opened this issue Oct 10, 2023 · 3 comments
Assignees
Labels
infra/devops Related to infrastructure or project config

Comments

@chriswilty
Copy link
Member

chriswilty commented Oct 10, 2023

Use CDK to define a CodePipeline for building, testing and deploying stack resources.
https://docs.aws.amazon.com/cdk/v2/guide/cdk_pipeline.html

Notes

  • Merge to main branch will trigger pipeline deployment of "prod" stage
  • CDK Pipelines are self-updating, after initial manual deployment 🏆
  • Pipeline synthesizes and deploys all other (application) stacks

Concerns

Currently the individual stacks are not tested, so it is possible that stack synthesis or deployment could fail when the pipeline runs. We could at least trigger synth as part of the github cloud workflow, even if we do nothing with the output, but better would be to write construct tests.

Acceptance Criteria

  • Prod-stage pipeline can be synthesized locally and deployed to our SpyLogic AWS account
  • Pipeline is triggered on merge to main branch
  • Upon successful completion of pipeline run, new version of application is deployed to spylogic.ai
@chriswilty chriswilty added the infra/devops Related to infrastructure or project config label Oct 10, 2023
@chriswilty chriswilty added this to the Remote deployment milestone Oct 10, 2023
@chriswilty chriswilty self-assigned this Feb 16, 2024
@chriswilty
Copy link
Member Author

As I am being moved off the project, I am deprioritising this stack in favour of the Route53 / domain setup with authentication. My notes so far:

  • Newer CDK Pipelines looked promising until I realised there is no obvious way to deploy the UI as part of the pipeline, unlike with the original Code Pipelines API which has a dedicated S3Deploy action.
  • Might be possible using BucketDeployment, although the cache Invalidation is still a problem to solve, as is providing the necessary IAM policies.
  • Might be possible using a dedicated CodeBuild action; can that be added to a Stack, and then triggered from the pipeline?

@chriswilty
Copy link
Member Author

Update

I was able to get the pipeline working with the new CDK Pipelines API. I used a custom Step (see cloud/lib/constructs/DeployS3Step.ts) for deploying the built UI to the host bucket, and a CodeBuildStep (which can be configured with IAM access policies) to invalidate the CloudFront distribution cache.

Tested by deploying a dev stage pipeline. The pipeline auto-runs when first deployed, but in testing I used the cloud infrastructure feature branch as the pipeline trigger. Once teething problems had been ironed out and the pipeline succeeded, I was able to validate the deployed application at dev.spylogic.ai. I did not create a new SSO application in Azure, but adding a user to the dev UserPool allowed me to log in and interact with ScottBrewBot as expected.

This dev stage was subsequently destroyed so is no longer available, however, the templates allow deploying a pipeline for any named stage, and upon pipeline completion the UI will be available at https://{stagename}.spylogic.ai, with the API available at https://{stagename}.spyogic.ai/api.

@chriswilty
Copy link
Member Author

NOTE: Upon merge into main, I will synth the pipeline and deploy. However, I will first need to destroy the existing prod stacks as the pipeline will not recognise them as its own, so would fail with duplicate resource errors. It will mean a short downtime, so I will likely do this first thing in the morning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infra/devops Related to infrastructure or project config
Projects
None yet
Development

No branches or pull requests

1 participant