I have a pipeline in AWS with Codestar, CodeBuild, CloudFormation, etc.
I am trying to figure out how to get information from the CloudFormation step returned to the CodeBuild step. Let me break it down:
I have a
buildspec.yml
for CodeBuild# buildspec.yml ... phases: ... build: commands: - aws cloudformation package --region $REGION --template template.yml --s3-bucket $S3_BUCKET --output-template $OUTPUT_TEMPLATE
The above kicks off a CloudFormation build using our
template.yml
# template.yml ... S3BucketAssets: Type: AWS::S3::Bucket ...
At this point, it creates a unique name for an S3 bucket. Awesome. Now, for step 2 in my
buildspec.yml
for CodeBuild, I want to push items to the S3 bucket just created in the CloudFormation template. BUT, I don't know how to get the dynamically created name of the S3 bucket from the CloudFormation template. I want something similar to:# buildspec.yml ... phases: ... build: commands: # this is the same step as shown above - aws cloudformation package --region $REGION --template template.yml --s3-bucket $S3_BUCKET --output-template $OUTPUT_TEMPLATE # this is the new step - aws s3 sync dist_files/ s3://{NAME_OF_THE_NEW_S3_BUCKET}
How can I accomplish getting the dynamically named S3 bucket so that I can push to it?
I am aware that within a CloudFormation template, you can reference the S3 bucket name with something like !GetAtt [ClientWebAssets, WebsiteURL]
. But, I do not know how to get that information out of the cloudformation template and back into the codebuild template.