- Newest
- Most votes
- Most comments
Hello.
I think you are probably running sam deploy within CodeBuild, but how about specifying the environment with "--config-env" as an option for sam deploy?
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/deploying-using-codepipeline.html
Parameters can also be separated by separating the environments with "--config-env".
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-config.html#serverless-sam-cli-config-basics
Thanks Riku, at the moment I am using a single two-stage pipeline created by the template as described in the workshop I understand it is possible to do this if I create a separate pipeline for each environment but I just wanted to check if there is any way to achieve this without having to create a new pipeline? Using the existing two-stage pipeline? Is that not possible?
Relevant content
- Accepted Answerasked 3 months ago
- asked 3 months ago
- Accepted Answerasked 10 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 3 years ago
Thanks Riku, Yes I am running sam deploy with codebuild, and I guess the approach you suggested requires manually editing the buildspec_deploy.yml? At first I thought the buildspec files are autogenerated based on the contents of the codepipeline.yaml so should not be modified manually as they would be overwritten next time. But now I can see the codepiple.yaml actually refers to the the buildspec file so I guess I was wrong about this. So please can you confirm, is it ok to manully edit the buildspec files to pass additional parameters when using it alongside codebuild, codepipeline.yaml etc? Also can you post an example to show how to let it pick up the stack name automatically as a parameter? I have dev and prod stacks and I guess I will have to access the stack name from without the codepipeline.yaml so that I can specify the stack name as a suffix to resource names (like the name of the dynamo db table)
It is possible to set environment variables in buildspec.yml. I think you can use this function to change the settings for each environment. In other words, I thought it would be a good idea to create a CodePipeline for each environment and create a branch for each environment. https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec.env https://docs.aws.amazon.com/codebuild/latest/userguide/change-project-console.html#change-project-console-environment
template.yml
samconfig.toml