英文:
Expansion of variables / functions in Cloud Formation YAML
问题
I'm trying to learn how to write Cloud Formation templates (in YAML) by hand. I'm finding the iteration process quite slow and, therefore, learning by 'trial and error' also slow. For example, I'm trying to figure out if this:
Fn::Join:
- "/"
- - "s3:/"
- !Ref MyBucket
- "deviceFeed"
could be replaced with this:
!Sub "s3://${MyBucket}/deviceFeed"
Is there someway that I can quickly run my YAML through a process to expand out functions like these and see the final rendered strings, etc.? Perhaps something in the CLI or console? At the moment I'm just deploying the stacks and trawling through the errors, then guessing the mistake. My pace is glacial on a particularly cold day. I need a way to move faster. Any tips greatly appreciated.
英文:
I'm trying to learn how to write Cloud Formation templates (in YAML) by hand.
I'm finding the iteration process quite slow and, therefore, learning by 'trial and error' also slow.
For example, I'm trying to figure out if this:
Fn::Join:
- "/"
- - "s3:/"
- !Ref MyBucket
- "deviceFeed"
could be replaced with this:
!Sub "s3://${MyBucket}/deviceFeed"
(I have no idea of the answer to that question btw... and the answer is not what I'm asking here).
Is there someway that I can quickly run my YAML through a process to expand out functions like these and see the final rendered strings etc? Perhaps something in the CLI or console? At the moment I'm just deploying the stacks and trawling through the errors, then guessing the mistake. My pace is glacial on a particularly cold day. I need a way to move faster.
Any tips greatly appreciated.
答案1
得分: 1
I do not have 50+ reputation points, so I'm leaving an answer. That being said...
First:
!Sub "s3://${MyBucket}/deviceFeed"
This is perfectly correct and even better than Fn::Join in plain YAML CloudFormation templates. !Ref to MyBucket would return the name of the bucket.
Reference on S3 Buckets return values
Second:
CloudFormation doesn't provide a feature like terraform's plan command. And as @jarmod said, !Ref's to resources created in the template will only return values after creation. A way to have a dry run report, is creating changesets... The changeset will show you what will change in your stack, but won't help much if there are errors in the template as it doesn't run deep lint checks on the yaml file.
Here's an article that goes deep into cloudformation changesets
英文:
I do not have 50+ reputation points, so I'm leaving an answer. That being said...
First:
!Sub "s3://${MyBucket}/deviceFeed"
This is perfectly correct and even better than Fn::Join in plain YAML CloudFormation templates. !Ref to MyBucket would return the name of the bucket.
Reference on S3 Buckets return values
Second:
CloudFormation doesn't provide a feature like terraform's plan command. And as @jarmod said, !Ref's to resources created in the template will only return values after creation. A way to have a dry run report, is creating changesets... The changeset will show you what will change in your stack, but won't help much if there are errors in the template as it doesn't run deep lint checks on the yaml file.
Here's an article that goes deep in to cloudformation changesets
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论