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

refactor: Switch to using an auto-generated riff-raff.yaml file #659

Closed
wants to merge 1 commit into from

Conversation

akash1810
Copy link
Member

@akash1810 akash1810 commented Aug 20, 2022

Part of #645.

What does this change?

In this change we move to an auto-generated riff-raff.yaml file using @guardian/cdk, a feature released in v47.1.0.

Why?

Primarily, this is to test the experimental1 GuCDK feature "in the wild". But also, it simplifies things a little; should we wish to deploy to another region, we'd now just need to update the cdk.ts file and the generated riff-raff.yaml file will include the new region.

Notes

The manual riff-raff.yaml explicitly names the CloudFormation stack to deploy to, whereas the auto-generated file opts to use tag discovery (Stack, Stage, and App tags).

We need to ensure these tags are present on the CloudFormation stacks before shipping this, else Riff-Raff will try to create a new CFN stack (and fail), which is undesired! Update: Riff-Raff is applying the standard SSA tags to CloudFormation stacks since guardian/riff-raff#934. That is, the aforementioned concern is no longer present.

Content of generated file
allowedStages:
  - CODE
  - PROD
deployments:
  lambda-upload-eu-west-1-cmp-monitoring-cmp-monitoring-lambda-eu-west-1:
    type: aws-lambda
    stacks:
      - cmp-monitoring
    regions:
      - eu-west-1
    app: cmp-monitoring-lambda-eu-west-1
    contentDirectory: cmp-monitoring-lambda-eu-west-1
    parameters:
      bucketSsmLookup: true
      lookupByTags: true
      fileName: cmp-monitoring-lambda-eu-west-1.zip
    actions:
      - uploadLambda
  cfn-eu-west-1-cmp-monitoring-monitoring:
    type: cloud-formation
    regions:
      - eu-west-1
    stacks:
      - cmp-monitoring
    app: monitoring
    contentDirectory: cdk.out
    parameters:
      templateStagePaths:
        CODE: CmpMonitoringStackEUCode.template.json
        PROD: CmpMonitoringStackEUProd.template.json
    dependencies:
      - lambda-upload-eu-west-1-cmp-monitoring-cmp-monitoring-lambda-eu-west-1
  lambda-update-eu-west-1-cmp-monitoring-cmp-monitoring-lambda-eu-west-1:
    type: aws-lambda
    stacks:
      - cmp-monitoring
    regions:
      - eu-west-1
    app: cmp-monitoring-lambda-eu-west-1
    contentDirectory: cmp-monitoring-lambda-eu-west-1
    parameters:
      bucketSsmLookup: true
      lookupByTags: true
      fileName: cmp-monitoring-lambda-eu-west-1.zip
    actions:
      - updateLambda
    dependencies:
      - cfn-eu-west-1-cmp-monitoring-monitoring
  lambda-upload-us-west-1-cmp-monitoring-cmp-monitoring-lambda-us-west-1:
    type: aws-lambda
    stacks:
      - cmp-monitoring
    regions:
      - us-west-1
    app: cmp-monitoring-lambda-us-west-1
    contentDirectory: cmp-monitoring-lambda-us-west-1
    parameters:
      bucketSsmLookup: true
      lookupByTags: true
      fileName: cmp-monitoring-lambda-us-west-1.zip
    actions:
      - uploadLambda
  cfn-us-west-1-cmp-monitoring-monitoring:
    type: cloud-formation
    regions:
      - us-west-1
    stacks:
      - cmp-monitoring
    app: monitoring
    contentDirectory: cdk.out
    parameters:
      templateStagePaths:
        CODE: CmpMonitoringStackUSCode.template.json
        PROD: CmpMonitoringStackUSProd.template.json
    dependencies:
      - lambda-upload-us-west-1-cmp-monitoring-cmp-monitoring-lambda-us-west-1
  lambda-update-us-west-1-cmp-monitoring-cmp-monitoring-lambda-us-west-1:
    type: aws-lambda
    stacks:
      - cmp-monitoring
    regions:
      - us-west-1
    app: cmp-monitoring-lambda-us-west-1
    contentDirectory: cmp-monitoring-lambda-us-west-1
    parameters:
      bucketSsmLookup: true
      lookupByTags: true
      fileName: cmp-monitoring-lambda-us-west-1.zip
    actions:
      - updateLambda
    dependencies:
      - cfn-us-west-1-cmp-monitoring-monitoring
  lambda-upload-ap-southeast-2-cmp-monitoring-cmp-monitoring-lambda-ap-southeast-2:
    type: aws-lambda
    stacks:
      - cmp-monitoring
    regions:
      - ap-southeast-2
    app: cmp-monitoring-lambda-ap-southeast-2
    contentDirectory: cmp-monitoring-lambda-ap-southeast-2
    parameters:
      bucketSsmLookup: true
      lookupByTags: true
      fileName: cmp-monitoring-lambda-ap-southeast-2.zip
    actions:
      - uploadLambda
  cfn-ap-southeast-2-cmp-monitoring-monitoring:
    type: cloud-formation
    regions:
      - ap-southeast-2
    stacks:
      - cmp-monitoring
    app: monitoring
    contentDirectory: cdk.out
    parameters:
      templateStagePaths:
        CODE: CmpMonitoringStackAPCode.template.json
        PROD: CmpMonitoringStackAPProd.template.json
    dependencies:
      - >-
        lambda-upload-ap-southeast-2-cmp-monitoring-cmp-monitoring-lambda-ap-southeast-2
  lambda-update-ap-southeast-2-cmp-monitoring-cmp-monitoring-lambda-ap-southeast-2:
    type: aws-lambda
    stacks:
      - cmp-monitoring
    regions:
      - ap-southeast-2
    app: cmp-monitoring-lambda-ap-southeast-2
    contentDirectory: cmp-monitoring-lambda-ap-southeast-2
    parameters:
      bucketSsmLookup: true
      lookupByTags: true
      fileName: cmp-monitoring-lambda-ap-southeast-2.zip
    actions:
      - updateLambda
    dependencies:
      - cfn-ap-southeast-2-cmp-monitoring-monitoring
  lambda-upload-ca-central-1-cmp-monitoring-cmp-monitoring-lambda-ca-central-1:
    type: aws-lambda
    stacks:
      - cmp-monitoring
    regions:
      - ca-central-1
    app: cmp-monitoring-lambda-ca-central-1
    contentDirectory: cmp-monitoring-lambda-ca-central-1
    parameters:
      bucketSsmLookup: true
      lookupByTags: true
      fileName: cmp-monitoring-lambda-ca-central-1.zip
    actions:
      - uploadLambda
  cfn-ca-central-1-cmp-monitoring-monitoring:
    type: cloud-formation
    regions:
      - ca-central-1
    stacks:
      - cmp-monitoring
    app: monitoring
    contentDirectory: cdk.out
    parameters:
      templateStagePaths:
        CODE: CmpMonitoringStackCACode.template.json
        PROD: CmpMonitoringStackCAProd.template.json
    dependencies:
      - >-
        lambda-upload-ca-central-1-cmp-monitoring-cmp-monitoring-lambda-ca-central-1
  lambda-update-ca-central-1-cmp-monitoring-cmp-monitoring-lambda-ca-central-1:
    type: aws-lambda
    stacks:
      - cmp-monitoring
    regions:
      - ca-central-1
    app: cmp-monitoring-lambda-ca-central-1
    contentDirectory: cmp-monitoring-lambda-ca-central-1
    parameters:
      bucketSsmLookup: true
      lookupByTags: true
      fileName: cmp-monitoring-lambda-ca-central-1.zip
    actions:
      - updateLambda
    dependencies:
      - cfn-ca-central-1-cmp-monitoring-monitoring

Footnotes

  1. "Experimental" sounds risky, some background can be found here. The feature is being used in PROD today too.

@akash1810 akash1810 force-pushed the aa-generate-riffraff-yaml branch 2 times, most recently from 9f4546f to 2d12508 Compare October 12, 2022 15:47
@akash1810 akash1810 marked this pull request as ready for review October 12, 2022 16:51
@akash1810 akash1810 requested a review from a team October 12, 2022 17:30
@akash1810
Copy link
Member Author

Closing after no activity in over 30 days.

@akash1810 akash1810 closed this Mar 31, 2023
@akash1810 akash1810 deleted the aa-generate-riffraff-yaml branch March 31, 2023 19:52
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.

None yet

1 participant