Search code examples
amazon-web-servicesaws-codepipelineamazon-systems-manager

Is there a way to use an SSM Parameter to provide the path for an S3 deployment in CodePipeline


So, I've got a simple CodePipeline setup that uses CodeBuild to put some artifacts together and then provisions a CloudFormation Stack.

One of the resources created is an S3 bucket for storing static files. It also creates an SSM parameter with the name of the bucket.

Currently, to deploy to the bucket I'm using an S3 stage to unpack the initial set of files. Unfortunately I can only figure out how to set the bucket manually. This works ok if the stack is already provisioned but fails if the stack is created from fresh (with a new bucket name assigned).

Is there a way I can use the SSM parameter as part of this stage that I'm not seeing?


Solution

  • I agree with @shariqmaws. You can save the environment variable in SSM parameter store and can use that variable as follows:

    env:
      parameter-store:
        key: value
    

    Once that's done, you can use that variable as follows:

    aws s3 sync your-s3-files/ "s3://${key}"