aws-cloudformation / aws-cloudformation/cloudformation-coverage-roadmap
AWS::CloudFormation -- Improve validation to report error file, line number, and attribute
- Dominant language
- No language data
- Stars
- 1.1k
- Forks
- 62
- PR merge metrics
- No merged PRs in 30d
Description
## AWS::CloudFormation -- Improve validation to report error file, line number, and attribute
## AWS::CloudFormation -- ValidateTemplate operation reports error but with insufficient context to understand and fix
## 3. Expected behavior
I get an error:
```
An error occurred (ValidationError) when calling the ValidateTemplate operation: Template error: variable names in Fn::Sub syntax must contain only alphanumeric characters, underscores, periods, and colons
```
But would like it to suffix with file and line number where the error occurred, e.g.,
```
... at nested stack ttt2service-stack.yml:370
Resource.LaunchConfig.Properties.UserData
```
## 4. Suggest specific test cases
I have a master stack, `ttt2.yml` which uses a nested `ttt2service-stack.yml`. Submitting ttt2.yml failed with the error above. It turns out I had bad quoting in the UserData of a LaunchConfig. But this was totally not determinable from the error message. My UserData problem was due to:
```
UserData:
Fn::Base64: !Sub |
#!/bin/bash -xe
yum update -y aws-cfn-bootstrap
/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource LaunchConfig --region ${AWS::Region}
docker_flags="""
--log-driver=awslogs
--log-opt awslogs-group=${LogGroupName}
-e AWS_DEFAULT_REGION=${AWS::Region}
...
"""
```
The message was not helpful, in fact, pointed in the wrong direction:
```
Template error: variable names in Fn::Sub syntax must contain only alphanumeric characters, underscores, periods, and colons
```
If CloudFormation had told me the nested file (on S3) and line number where it had the syntax problem, I could have saved a few hours of trial-and-error.
This is what I expect from a C compiler or Python interpreter. Not just "you did something wrong... somewhere."
## 5. Helpful Links to speed up research and evaluation
I whined about my slog here, and you replied I should file this ticket.
https://twitter.com/Shentonfreude/status/1393222974703083529
## 6. Category (required) - Will help with tagging and be easier to find by other users to +1
5. Management (CloudTrail, Config...)
## 7. Any additional context (optional)
none.
Contributor guide
Research direction
Reproduce the ValidateTemplate failure using ttt2.yml and the nested ttt2service-stack.yml, focusing on the Fn::Sub error in UserData. Then locate the validation path and existing error tests for the ValidateTemplate operation. Done means the error identifies the nested template file, line number, and attribute path such as Resource.LaunchConfig.Properties.UserData.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws
- Domain
- cloud, infrastructure
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100