r/aws•
8solutions

Is the cloudformation team sadistic, selfish, or just stupid? Nested stacks must reference each other via an S3 url, why?

technical question

Every time I prepare to use nested stacks, I always check to see whether the deployment process has changed or if it is still has the imbecilic requirement that we upload template files with an s3 url to the child template files, instead of simply uploading a zip file with local references. I guess the benefit is that you can reuse your stupid cloudformation templates across stacks by pointing to them? That's great but could we just have the option to upload a zip archive instead? Or, better yet, upload a zip archive directly to the Cloudformation service so that we don't need to create an s3 bucket? This adds 2 or 3 build steps for deploying infrastructure and its always felt clunky.

Does AWS benefit from this schema in some way?

Anyways, good morning everybody I hope you are doing well

Posted Nov 6, 2019, 3:54 PM UTC

319
SeverusSlytherin•

You might want to look at the "package" command in the cli. The project I'm working with run it as part of our codebuild stage.

https://docs.aws.amazon.com/cli/latest/reference/cloudformation/package.html

"Packages the local artifacts (local paths) that your AWS CloudFormation template references. The command uploads local artifacts, such as source code for an AWS Lambda function or a Swagger file for an AWS API Gateway REST API, to an S3 bucket. The command returns a copy of your template, replacing references to local artifacts with the S3 location where the command uploaded the artifacts.

Use this command to quickly upload local artifacts that might be required by your template. After you package your template's artifacts, run the deploy command to deploy the returned template."

7
sasquatch989•

Not AWS, but Azure has the same problems with ARM templates and storage accounts. I feel your pain and absolutely agree it's imbecilic from a usability perspective for the vast majority of use cases

1
TRUMP_RAPED_WOMEN•

Is an Azure storage account similar to a AWS S3 bucket?

1
filthydiarrhoea•

You'll find AWS uses a bucket in the backend for Cloudformation in any case, it creates a bucket in your account and any template files you upload are uploaded to that bucket.

That said I do get where you're coming from, but it may be worthwhile for you to have a look at CodePipeline, you can set S3 as a source and then have it deploy your template in the next step, or you could set a GitHub repository as the source and have CodePipeline upload all your template files and then run the Cloudformation deployment for you. The only downside is that you'll run into a "chicken and egg" situation where you need to deploy the pipeline through a separate stack but that doesn't have to be a nested stack. The big advantage to this approach is that any changes you make to the parent or nested template will be deployed without anymore input from you.

Edit: here's a quick reference deployment https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/continuous-delivery-codepipeline-basic-walkthrough.html

1
puterSciGrrl•

Trick i learned to address chicken/egg. You can set "restart on update" and deploy a seed pipeline. The pipeline executes first time and grabs a config template which includes it's own definition. It redeploys ITSELF, triggering a restart with the whole pipeline definition included and does the full system deploy on this second pass.

3
8solutionsOP•

Neat trick, thanks!

1
matluck•

Have you tried separating it into stacks and using cfn export/import? Since that feature came along I haven't even thought about nested stacks as its such a headache.

1
acid_sphinx4•

Sadistic for sure. Don't see how anyone can use CF it's such a piece of shit

0
8solutionsOP•

What do you use?

1
mb323•

Use Terraform, done

3
8solutionsOP•

I hear terraform is mired in its own problems that don't sound much different from cloudformation's

3
acid_sphinx4•

It's night and day.

3
mb323•

I'll let you make your own determination, but imo, it's far superior. It has great documentation, is generally easy to use, and supports platforms and services outside of AWS. Just look at the support: https://www.terraform.io/docs/providers/index.html

1
acid_sphinx4•

Terraform, salt cloud

1