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

fix: update cfn-lint versions and match tests #3651

Merged
merged 5 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .cfnlintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,12 @@ ignore_templates:
- tests/translator/output/**/function_with_tracing.json # Obsolete DependsOn on resource
- tests/translator/output/**/api_with_propagate_tags.json # TODO: Intentional error transform tests. Will be updated.
- tests/translator/output/**/function_with_intrinsics_resource_attribute.json # CFN now supports intrinsics in DeletionPolicy
- tests/translator/output/**/function_with_snapstart.json # Snapstart intentionally not attached to a lambda version which causes lint issues
- tests/translator/output/**/managed_policies_everything.json # intentionally contains wrong arns
ignore_checks:
- E2531 # Deprecated runtime; not relevant for transform tests
- E2533 # Another deprecated runtime; not relevant for transform tests
- W2531 # EOL runtime; not relevant for transform tests
- E3001 # Invalid or unsupported Type; common in transform tests since they focus on SAM resources
- W2001 # Parameter not used
- E3006 # Resource type check; we have some Foo Bar resources
2 changes: 1 addition & 1 deletion bin/run_cfn_lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if [ ! -d "${VENV}" ]; then
python3 -m venv "${VENV}"
fi

"${VENV}/bin/python" -m pip install cfn-lint==0.75.0 --upgrade --quiet
"${VENV}/bin/python" -m pip install cfn-lint --upgrade --quiet
# update cfn schema
"${VENV}/bin/cfn-lint" -u
"${VENV}/bin/cfn-lint" --format parseable
2 changes: 1 addition & 1 deletion tests/translator/input/all_policy_templates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Resources:
EventBusName: name

- AcmGetCertificatePolicy:
CertificateArn: arn
CertificateArn: arn:aws:acm:us-west-2:987654321098:certificate/dec86919-7219-4e8d-8871-7f1609df2c7f
aaythapa marked this conversation as resolved.
Show resolved Hide resolved

- Route53ChangeResourceRecordSetsPolicy:
HostedZoneId: test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Resources:
Principal:
Service: lambda.amazonaws.com
ManagedPolicyArns:
- arn:{AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
- !Sub arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole

SamFunction:
Type: AWS::Serverless::Function
Expand Down
15 changes: 15 additions & 0 deletions tests/translator/input/embedded_connectors_hardcoded_props.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ Transform: AWS::Serverless-2016-10-31
Resources:
MyFunction:
Type: AWS::Lambda::Function
Properties:
Handler: index.handler
Role: arn:aws:iam::111122223333:role/lambda-role
Runtime: nodejs20.x
Code:
ZipFile: |
exports.handler = function(event, context, callback) {
return callback(null, 'success');
}

MyRule:
Type: AWS::Events::Rule
Expand All @@ -13,6 +22,8 @@ Resources:
Arn: !Ref MyTopic
Permissions:
- Write
Properties:
ScheduleExpression: rate(5 minutes)

MyQueue:
Type: AWS::SQS::Queue
Expand Down Expand Up @@ -42,6 +53,8 @@ Resources:
Id: MyFunction
Permissions:
- Write
Properties:
Name: MyApiV1

MyApiV2:
Type: AWS::ApiGatewayV2::Api
Expand All @@ -54,6 +67,8 @@ Resources:
Id: MyFunction
Permissions:
- Write
Properties:
Name: MyApiV2

MySNSTopic:
Type: AWS::SNS::Topic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Resources:
- x86_64
EphemeralStorage:
Size: 1024
Role: !Sub arn:${AWS::Partition}:iam::role
Role: !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/role1
KmsKeyArn: !Sub arn:${AWS::Partition}:key:key
FileSystemConfigs:
- Arn: !GetAtt AccessPoint.Arn
Expand Down Expand Up @@ -72,7 +72,7 @@ Resources:
- x86_64
EphemeralStorage:
Size: 1024
Role: !Sub arn:${AWS::Partition}:iam::role
Role: !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/role1
KmsKeyArn: !Sub arn:${AWS::Partition}:key:key
FileSystemConfigs:
- Arn: !GetAtt AccessPoint.Arn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Resources:
NotificationTopic:
Type: SNS
Properties:
Topic: topicArn-letsAddMoreSymbols
Topic: arn:aws:sns:us-west-2:987654321098:key/dec86919-7219-4e8d-8871-7f1609df2c7f
Region: region
FilterPolicy:
store:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Resources:
DynamoDb:
MyDataSource:
TableName: some-table
TableArn: big-arn
TableArn: arn:aws:dynamodb:us-west-2:987654321098:table/dec86919-7219-4e8d-8871-7f1609df2c7f
AnotherDataSource:
TableName: cool-table
TableArn: table-arn
TableArn: arn:aws:dynamodb:us-west-2:987654321098:table/dec86919-7219-4e8d-8871-7f1609df2c7f
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ Resources:
DataSources:
Lambda:
MyDataSource:
FunctionArn: blah
FunctionArn: arn:aws:lambda:us-west-2:987654321098:function:dec86919-7219-4e8d-8871-7f1609df2c7f
2 changes: 1 addition & 1 deletion tests/translator/output/all_policy_templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,7 @@
"Fn::Sub": [
"${certificateArn}",
{
"certificateArn": "arn"
"certificateArn": "arn:aws:acm:us-west-2:987654321098:certificate/dec86919-7219-4e8d-8871-7f1609df2c7f"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion tests/translator/output/aws-cn/all_policy_templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,7 @@
"Fn::Sub": [
"${certificateArn}",
{
"certificateArn": "arn"
"certificateArn": "arn:aws:acm:us-west-2:987654321098:certificate/dec86919-7219-4e8d-8871-7f1609df2c7f"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@
]
},
"ManagedPolicyArns": [
"arn:{AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
{
"Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
}
]
},
"Type": "AWS::IAM::Role"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"Resources": {
"MyApiV1": {
"Properties": {
"Name": "MyApiV1"
},
"Type": "AWS::ApiGateway::RestApi"
},
"MyApiV1ApiV1ToLambdaWriteLambdaPermission": {
Expand Down Expand Up @@ -40,6 +43,9 @@
"Type": "AWS::Lambda::Permission"
},
"MyApiV2": {
"Properties": {
"Name": "MyApiV2"
},
"Type": "AWS::ApiGatewayV2::Api"
},
"MyApiV2ApiV2ToLambdaWriteLambdaPermission": {
Expand Down Expand Up @@ -79,6 +85,14 @@
"Type": "AWS::Lambda::Permission"
},
"MyFunction": {
"Properties": {
"Code": {
"ZipFile": "exports.handler = function(event, context, callback) {\n return callback(null, 'success');\n}\n"
},
"Handler": "index.handler",
"Role": "arn:aws:iam::111122223333:role/lambda-role",
"Runtime": "nodejs20.x"
},
"Type": "AWS::Lambda::Function"
},
"MyQueue": {
Expand All @@ -88,6 +102,9 @@
"Type": "AWS::SQS::Queue"
},
"MyRule": {
"Properties": {
"ScheduleExpression": "rate(5 minutes)"
},
"Type": "AWS::Events::Rule"
},
"MyRuleRuleToTopicTopicPolicy": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"PackageType": "Zip",
"ReservedConcurrentExecutions": 100,
"Role": {
"Fn::Sub": "arn:${AWS::Partition}:iam::role"
"Fn::Sub": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/role1"
},
"Runtime": "python2.7",
"Tags": [
Expand Down Expand Up @@ -74,15 +74,15 @@
},
"FunctionVersion": {
"Fn::GetAtt": [
"HashChangeFunctionVersion17ca83d2bf",
"HashChangeFunctionVersiona1a9d4d1e4",
"Version"
]
},
"Name": "live"
},
"Type": "AWS::Lambda::Alias"
},
"HashChangeFunctionVersion17ca83d2bf": {
"HashChangeFunctionVersiona1a9d4d1e4": {
"DeletionPolicy": "Retain",
"Properties": {
"Description": "sam-testing",
Expand Down Expand Up @@ -127,7 +127,7 @@
"PackageType": "Zip",
"ReservedConcurrentExecutions": 100,
"Role": {
"Fn::Sub": "arn:${AWS::Partition}:iam::role"
"Fn::Sub": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/role1"
},
"Runtime": "python2.7",
"Tags": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"FilterPolicyScope": "MessageAttributes",
"Protocol": "lambda",
"Region": "region",
"TopicArn": "topicArn-letsAddMoreSymbols"
"TopicArn": "arn:aws:sns:us-west-2:987654321098:key/dec86919-7219-4e8d-8871-7f1609df2c7f"
},
"Type": "AWS::SNS::Subscription"
},
Expand All @@ -73,7 +73,7 @@
"Ref": "MyAwesomeFunction"
},
"Principal": "sns.amazonaws.com",
"SourceArn": "topicArn-letsAddMoreSymbols"
"SourceArn": "arn:aws:sns:us-west-2:987654321098:key/dec86919-7219-4e8d-8871-7f1609df2c7f"
},
"Type": "AWS::Lambda::Permission"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@
],
"Effect": "Allow",
"Resource": [
"table-arn",
"arn:aws:dynamodb:us-west-2:987654321098:table/dec86919-7219-4e8d-8871-7f1609df2c7f",
{
"Fn::Sub": [
"${DestinationArn}/index/*",
{
"DestinationArn": "table-arn"
"DestinationArn": "arn:aws:dynamodb:us-west-2:987654321098:table/dec86919-7219-4e8d-8871-7f1609df2c7f"
}
]
}
Expand All @@ -127,12 +127,12 @@
],
"Effect": "Allow",
"Resource": [
"table-arn",
"arn:aws:dynamodb:us-west-2:987654321098:table/dec86919-7219-4e8d-8871-7f1609df2c7f",
{
"Fn::Sub": [
"${DestinationArn}/index/*",
{
"DestinationArn": "table-arn"
"DestinationArn": "arn:aws:dynamodb:us-west-2:987654321098:table/dec86919-7219-4e8d-8871-7f1609df2c7f"
}
]
}
Expand Down Expand Up @@ -248,12 +248,12 @@
],
"Effect": "Allow",
"Resource": [
"big-arn",
"arn:aws:dynamodb:us-west-2:987654321098:table/dec86919-7219-4e8d-8871-7f1609df2c7f",
{
"Fn::Sub": [
"${DestinationArn}/index/*",
{
"DestinationArn": "big-arn"
"DestinationArn": "arn:aws:dynamodb:us-west-2:987654321098:table/dec86919-7219-4e8d-8871-7f1609df2c7f"
}
]
}
Expand All @@ -271,12 +271,12 @@
],
"Effect": "Allow",
"Resource": [
"big-arn",
"arn:aws:dynamodb:us-west-2:987654321098:table/dec86919-7219-4e8d-8871-7f1609df2c7f",
{
"Fn::Sub": [
"${DestinationArn}/index/*",
{
"DestinationArn": "big-arn"
"DestinationArn": "arn:aws:dynamodb:us-west-2:987654321098:table/dec86919-7219-4e8d-8871-7f1609df2c7f"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
]
},
"LambdaConfig": {
"LambdaFunctionArn": "blah"
"LambdaFunctionArn": "arn:aws:lambda:us-west-2:987654321098:function:dec86919-7219-4e8d-8871-7f1609df2c7f"
},
"Name": "MyDataSource",
"ServiceRoleArn": {
Expand Down Expand Up @@ -123,12 +123,12 @@
],
"Effect": "Allow",
"Resource": [
"blah",
"arn:aws:lambda:us-west-2:987654321098:function:dec86919-7219-4e8d-8871-7f1609df2c7f",
{
"Fn::Sub": [
"${DestinationArn}:*",
{
"DestinationArn": "blah"
"DestinationArn": "arn:aws:lambda:us-west-2:987654321098:function:dec86919-7219-4e8d-8871-7f1609df2c7f"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,7 @@
"Fn::Sub": [
"${certificateArn}",
{
"certificateArn": "arn"
"certificateArn": "arn:aws:acm:us-west-2:987654321098:certificate/dec86919-7219-4e8d-8871-7f1609df2c7f"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@
]
},
"ManagedPolicyArns": [
"arn:{AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
{
"Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
}
]
},
"Type": "AWS::IAM::Role"
Expand Down
Loading