-
Notifications
You must be signed in to change notification settings - Fork 4k
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
aws-imagebuilder: wrong case in CFN template for properties of AmiDistributionConfiguration #26912
Comments
This is a cfnspec patch issue and we are tracking at #21767 At this moment, you will need to specify a JSON for dist_prop = cdk.aws_imagebuilder.CfnDistributionConfiguration.DistributionProperty(
region="eu-central-1",
ami_distribution_configuration={ "AmiTags": { "Key": "Value"}}
) Please check this sample for your reference. |
|
Hi I am offering a full working sample now. Please note according to the CDK Python API doc as ami_distribution_configuration is type
Check out my full working sample below: from aws_cdk import (
CustomResource,
CfnOutput,
Stack,
custom_resources as cr,
aws_imagebuilder as imagebuilder,
aws_lambda as lambda_,
)
from constructs import Construct
import os
class IssueTriagePyStack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
# The code that defines your stack goes here
ec2_distribution_configuration = imagebuilder.CfnDistributionConfiguration(self,
id=f"ToolingTeamcityAmzn2023BaseDistributionConfiguration",
description="Some description",
distributions=[
imagebuilder.CfnDistributionConfiguration.DistributionProperty(
region="us-east-1",
ami_distribution_configuration={
"AmiTags": {
"BuildVersion": "{{ imagebuilder:buildVersion }}",
"CostCenter": "hosting-deployment",
"Created": "{{ imagebuilder:buildDate }}",
"Description": "some description",
"Name": "some name",
"Region": "us-east-1",
"Version": "1.0.0",
},
"Description": "some description",
"LaunchPermissionConfiguration": {
"UserIds": ["123456789012"],
},
"Name": "some name - {{ imagebuilder:buildDate }}"
}
)
],
name="some name",
tags={
"ConfigurationDescription": "some description",
"ConfigurationName": "some name",
"CostCenter": "hosting-deployment",
},
) And the synthesized output from CDK is like
And you should not see any warning in cloudformation console. As mentioned above this is a cfnspec issue and we are tracking in issue#21767. At this moment we need to specify the full JSON as describe above. |
Describe the bug
I am deploying an EC2 Image Builder pipeline using CDK using the auto generated L1 constructs.
To configure how AMIs are distributed by the pipeline I am using
CfnDistributionConfiguration.AmiDistributionConfigurationProperty
(documentation here) which corresponds to AWS::ImageBuilder::DistributionConfiguration::AmiDistributionConfiguration.The problem that I observed is that the properties of
AmiDistributionConfiguration
in the synthesized CloudFormation templated are generated in camel case (e.g.,targetAccountIds
) while they should be given in title case (e.g.,TargetAccountIds
).The Image Builder pipeline is deployed and apparently works as specified, but this could be hinting at a bug somewhere so I'm reporting here.
Expected Behavior
Properties of
AmiDistributionConfiguration
in the synthesized should be generated with title case (e.g.,TargetAccountIds
).Current Behavior
Properties of
AmiDistributionConfiguration
in the synthesized are generated with title case (e.g.,targetAccountIds
) which not only triggerscfn-lint
but also leads to some non-fatal problems while deploying, as shown below.
Reproduction Steps
MWE for a Python CDK app with a distribution configuration that illustrates the issue:
This is the resource after synthesized:
As it can be seen the properties
amiTags
,description
,name
, andtargetAccountIds
are wrongly cased. This can be further illustrated by linting the resulting template:Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.93.0
Framework Version
No response
Node.js Version
18.16.1
OS
Ubuntu 22.04
Language
Python
Language Version
3.11.5
Other information
No response
The text was updated successfully, but these errors were encountered: