0

I'm trying to deploy nested stack using command

aws cloudformation deploy --stack-name "${STACK_NAME}" --template-file "${S3_ROOT_TEMPLATE}" --parameter-overrides ${PARAMS[@]} --region ${REGION}

But despite the S3_ROOT_TEMPLATE having proper url, I get the error

Invalid template path https://<s3-bucket-name>.s3.us-east-2.amazonaws.com/sm-domain-templates/main_stack.yaml

Any idea what's wrong with the above?

Shiva
  • 105
  • 1
  • 9

2 Answers2

0

Even though in the console you have to use S3 path, in the awscli command, it expects the local file path of the root stack file

Shiva
  • 105
  • 1
  • 9
0

The following command deploys a template named S3_ROOT_TEMPLATE to a stack named STACK_NAME:

STACK_NAME="cfn-demo"
S3_ROOT_TEMPLATE="cfn-demo.yaml"
REGION="us-east-1"
bucket_name="cfn-demo-bucket"
aws cloudformation deploy --stack-name $STACK_NAME --template-file $S3_ROOT_TEMPLATE --parameter-overrides $PARAMS[@] --region $REGION

If your templates are sized greater than 51,200 bytes, then the name of the S3 bucket where this command uploads your CloudFormation template.

aws cloudformation deploy --stack-name $STACK_NAME --template-file $S3_ROOT_TEMPLATE --parameter-overrides $PARAMS[@] --region $REGION  --s3-bucket $bucket_name

For updating the stack, you could upload the template file to the S3 bucket by using copy and then, update the stack by using the S3 object URL as the template source.

aws s3 cp $S3_ROOT_TEMPLATE s3://$bucket_name
aws cloudformation update-stack --stack-name $STACK_NAME --template-url https://$bucket_name.s3.$REGION.amazonaws.com/$S3_ROOT_TEMPLATE
Zeeshan
  • 357
  • 1
  • 8
  • Thank you Zeeshan, however with nested stack, I couldn't get the root stack file from S3 working - I had to use the local file that's pointing to S3 buckets using `TemplateUrl` like `TemplateURL: !Sub 'https://${S3BucketName}.s3.${AWS::Region}.${AWS::URLSuffix}/${S3KeyPrefix}/iam_stack.yaml'` – Shiva Oct 28 '22 at 00:39