3

I'm working on an interesting task and so far can't solve it.

Configuration:

  1. AWS code pipeline for backend which stores a value in SSM (@aws-cdk/aws-ssm)
  2. AWS code pipeline for frontend which builds a pipeline which builds project for React App
  3. React App git repository with buildspec.yml which consumed by pipeline from #2 and deployed to S3

Question: Any good way to read a value stored in #1 and inject it to React App?

I can easily read it in #2, but this project is for pipeline creation only. So, I think it requires some special step in pipeline for frontend to update React App during a build or deploy step.

Any brilliant ideas? :) I do not have any so far.

Thank you!

buildspec.yml code:

version: 0.2

phases:
  install:
    runtime-versions:
      nodejs: 12
    commands:
      - yarn install
  build:
    commands:
      - yarn build

artifacts:
  base-directory: ./build
  files:
    - '**/*'

cache:
  paths:
    - './node_modules/**/*'


John Rotenstein
  • 241,921
  • 22
  • 380
  • 470

2 Answers2

1

Ok, I've managed to inject Systems Manager value in React App with CDK. I did not find a way to do it with the initial setup (3 repositories). I had to merge #2 with #3 (so, front-end react app should be with cdk together).

In this setup, you can read Systems Manager value in cdk stack and add it to react with dynamic buildspec during the build step (buildspec from code).

0

I think that my example may be useful for you. I have ECS containers, the docker images are builded by a Jenkins server and uploaded to ECR. I use SSM Parameter Store to store environment variables. What do I do?

My ECS containers were deployed using cloudformation templates, when Jenkins finish to upload the new docker image to ECR then execute an update of my Cloudformation, in my cloudformation template I have macros (python functions that read from SSM Parameter Store the environment variables and put it in the cloudformation template), so the ECS task is update with the current version of my Parameter Store and with the latest docker image compilation. Also you can read from Jenkins the Parameter Store values, but I prefer the less possibles privileges in my Jenkins. Also by this way the cloudformation can be updated(to modify infrastructure components, etc.) and already has the macro implemented.

Miguel Conde
  • 813
  • 10
  • 22