aws / aws/aws-cli

Support passing local paths to nested CloudFormation stacks

Open
#6,961 3 comments 22 reactions 0 assignees View on GitHub
cloudformation package-deploy community customization feature-request p3
Dominant language
Python
Stars
17.3k
Forks
4.6k
Avg merge
1d 2h
Merged PRs (30d)
13

Description

### 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**:

```yaml
# 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](http://docs.aws.amazon.com/cli/latest/reference/cloudformation/package.html). 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.