0

I am trying to update a custom parameter on CloudFormation nested stack from console. It is updated but after code deployment, it gets default value. I want to save last updated value after deployment. I used a bash script as a build command on buildspec.yml. It works if there is a stack but does not work for a stack + a nested stack. Does anyone have any idea about it? I want to use this for updating a parameter from console without code deployment and save it for further usage if it is not changed.

console

publish.sh

mkdir -p build

# SAM Package
aws cloudformation package --template template-build.yml --s3-bucket ${DEPLOYMENT_BUCKET} --output-template build/template.yml --debug

# SAM Deploy
aws cloudformation deploy --template-file build/template.yml --stack-name ${STACK_NAME} --capabilities CAPABILITY_IAM CAPABILITY_AUTO_EXPAND --role-arn ${ROLE_ARN} \
        --s3-bucket $DEPLOYMENT_BUCKET \
        --parameter-overrides \
        DeploymentBucketName=${DEPLOYMENT_BUCKET} \
        NodeModulesZipFileName=${packageJsonHash}.zip

buildspec.yml

version: 0.2
phases:
  install:
    runtime-versions:
      python: 3.7
      nodejs: 10
    commands:
      - yum install python3-pip -y
      - whereis pip
      - pip3 install aws-sam-cli --upgrade --user
      - pip3 install awscli --upgrade --user
  pre_build:
    commands:
      - mkdir -p build/
  build:
    commands:
      - echo Build started on `date`
      - npm install --only=prod
      - chmod +x publish.sh
      - bash publish.sh
  post_build:
    commands:
      - echo "no post build needed..."
artifacts:
  type: zip
  files:
    - build/template.yml

rdvnkrtl
  • 11
  • 2
  • "It works if there is a stack but does not work for a stack + a nested stack" - what does it mean? You have to explain exactly what is happening. Any error messages? What are your templates? How anyone can reproduce the issue? – Marcin Aug 25 '21 at 22:08
  • If there is one root stack for project, script works. If there are one root stack and one nested stack that related root stack (you can see on https://i.stack.imgur.com/0v30t.png), script does not work. There is no error. Let's say I have a parameter like "password" on nested stack and default value is "1234", I update it from console like "5678" (you can see on pic). I want to save "5678" value after any code deployment but it gets default value ("1234"). – rdvnkrtl Aug 26 '21 at 07:11
  • You can create scenario like "create serverless app, add nested stack, add a customer parameter to nested stack, deploy app, update parameter value from console, do another deployment, see if that parameter gets default value or not." – rdvnkrtl Aug 26 '21 at 07:12
  • I mean "custom" not "customer". Sorry about that. – rdvnkrtl Aug 26 '21 at 15:26

0 Answers0