Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support passing local paths to nested CloudFormation stacks #6961

Open
2 tasks
justindho opened this issue May 17, 2022 · 3 comments
Open
2 tasks

Support passing local paths to nested CloudFormation stacks #6961

justindho opened this issue May 17, 2022 · 3 comments
Labels
cloudformation package-deploy community customization Issues related to CLI customizations (located in /awscli/customizations) feature-request A feature should be added or improved. p3 This is a minor priority issue

Comments

@justindho
Copy link
Contributor

Describe the feature

The idea is to map references in nested stacks to parameters passed in from its parent stack. The reference is parsed and replaced with the parameter's value (if the value is not dependent on a deploy time parameter) before the package command exports the resource's artifact to S3.


Example:

# package.yaml
AWSTemplateFormatVersion: 2010-09-09
Resources:
  ApiStack:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: ./api-template.yaml
      Parameters:
        SwaggerDoc: /path/to/swagger.yaml


# api-template.yaml
AWSTemplateFormatVersion: 2010-09-09
Parameters:
  SwaggerDoc:
    Type: String
Resources:
  MyFunction:
    Type: AWS::ApiGateway::RestApi
    Properties:
        BodyS3Location: !Ref SwaggerDoc

The command maps the parameter SwaggerDoc in api-template.yaml to the parameter value passed in from package.yaml (/path/to/swagger.yaml) before iterating over the resources. When it comes to the BodyS3Location property of MyFunction it will replace the !Ref SwaggerDoc with the value /path/to/swagger.yaml, then export that file to S3.


This feature also converts any relative paths to absolute paths by merging with the calling template's parent directory's path.


Example:

./swagger.yaml would become /absolute/path/to/swagger.yaml


This only affects the the specific properties of resources specified here. Any properties not specified in the previous link are not affected.

This is helpful for keeping things DRY when composing multiple connected local templates.

Use Case

I want nested stacks to be able to reference parameters passed in from their parent stack. This makes it easy to compose CloudFormation templates by connecting multiple local templates.

Proposed Solution

#2344

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CLI version used

any

Environment details (OS name and version, etc.)

any

@tim-finnigan tim-finnigan added customization Issues related to CLI customizations (located in /awscli/customizations) p3 This is a minor priority issue and removed cloudformation labels Nov 10, 2022
@LauricJurumani
Copy link

It is really annoying to have to push files to S3 in a deployment pipeline which deploys a nested CFN stack. Please fix this. :)

@Andr1500
Copy link

when this feature will be available in AWS::CloudFormation::Stack resource ? thank you.

@park-bitset
Copy link

park-bitset commented May 9, 2024

I think this is hard to achieve unless AWS releases a new version of template format.

Cloudformation templates must be available not only in deployment stage but other stages as well.
For example let's think of a case where you define a template(T1) of CodePipeline which uses another template(T2) for its deployment stage.
The contents of T1 is used when you deploy it, so you don't need to store it in S3.
On the other hand, T2 is used whenever the created CodePipeline is invoked.
Where should CodePipeline search for T2 if it's stored in a local computer?

Replacing the stack expression into unfolded nested stack contents might be an option.
But template file have a limit in it's length.

Separating AWS::Cloudformation::Stack into nested stacks, and currently used ordinary stacks might be an option too.
But considering the fact that there are no other places to write local paths in template file, I think maintaining the current way is better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cloudformation package-deploy community customization Issues related to CLI customizations (located in /awscli/customizations) feature-request A feature should be added or improved. p3 This is a minor priority issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants