CfnInclude: Changes to Mappings are recognized by diff but not deployed by deploy
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 74
Description
### Describe the bug
While deploying CloudFormation templates using CDK's CfnInclude module I noticed my changes were not deployed, although recognized by `cdk diff`. I see this happen if the only change between deployments is to the `Mappings` block, such as adding keys, updating values, etc.
As mentioned above, I can see the changes being outputted by `cdk diff` but the subsequent `cdk deploy` doesn't deploy changes and reports `No changes`. If I deploy the changes through the AWS Console, everything works as expected.
I tried with the `--method direct` and/or `--force` flags but this leads to another problem - https://github.com/aws/aws-cdk/issues/23141
### Expected Behavior
I expect changes to `Mappings` to be deployed with `cdk deploy`.
1. Make a change to the `Mappings` block in a CloudFormation template
2. Execute `cdk diff` (changes are outputted correctly)
3. Execute `cdk deploy` (changes are deployed correctly)
### Current Behavior
Changes to `Mappings` are not deployed with `cdk deploy`, although recognized by `cdk diff`.
1. Make a change to the `Mappings` block in a CloudFormation template (e.g., add another key to a map in Mappings)
2. Execute `cdk diff` (changes are outputted correctly)
3. Execute `cdk deploy` **(changes are NOT deployed)**
### Reproduction Steps
```python
# stack.py
class DeploymentStack(cdk.Stack):
def __init__(self, scope: Construct, construct_id: str, props: dict, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
template_file = "./template.yaml"
try:
_ = cfn_include.CfnInclude(
self,
"MyStackWithMappings",
template_file= template_file,
preserve_logical_ids=True,
)
except RuntimeError as error:
logger.error("Couldn't parse the template file %s.", template_file)
logger.error("Error: %s", error)
raise error
```
```yaml
# template.yaml
Mappings:
TestMapping:
PolicyName:
test: foo
prod: bar
Resources:
MyBucketPolicy:
Type: AWS::IAM::ManagedPolicy
Properties:
ManagedPolicyName: !FindInMap [TestMapping, PolicyName, test]
PolicyDocument:
Version: "2012-10-17"
Statement:
- Action: "s3:PutObject"
Resource: "*"
Effect: Allow
```
### Possible Solution
_No response_
### Additional Information/Context
_No response_
### CDK CLI Version
2.101.1
### Framework Version
_No response_
### Node.js Version
20.8.0
### OS
MacOS 14.0
### Language
Python
### Language Version
Python 3.11
### Other information
_No response_
Contributor guide
Research direction
Start with the CfnInclude entry point and the stack.py/template.yaml reproduction, then run cdk diff followed by cdk deploy on a Mappings-only change. Done means the mapping change is deployed rather than deploy reporting No changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python, typescript
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100