aws / aws/serverless-application-model

Resources created through the Serverless Transform contain hardcoded partitions in arns

Open
#1,590 8 comments 4 reactions 0 assignees View on GitHub
area/bestpractices maintainer/need-followup
Dominant language
Python
Stars
9.6k
Forks
2.5k
Avg merge
1d 11h
Merged PRs (30d)
7

Description

**Description:**

I am writing [custom linting scripts](https://github.com/aws-cloudformation/cfn-python-lint/issues/1522) to detect whether my cloudformation template has hardcoded Partitions and/or Regions. Templates processed by the SAM transform create ARnss with hardcoded Partitions.

For example this AWS::Lambda::Permission

```
"rCfnNagNotficationLambdaDevelopCfnNagPermission": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"Principal": "logs.amazonaws.com",
"FunctionName": {
"Ref": "rCfnNagNotficationLambda"
},
"SourceArn": {
"Fn::Sub": [
"arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:${__LogGroupName__}:*",
{
"__LogGroupName__": {
"Fn::GetAtt": [
"rDevelopPipeline",
"Outputs.oCfnNagLogGroupName"
]
}
}
]
}
}
```
Or this ManagedPolicyArn in this AWS::IAM::Role

```
"rUploadCustomCfnNagRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"sts:AssumeRole"
],
"Effect": "Allow",
"Principal": {
"Service": [
"lambda.amazonaws.com"
]
}
}
]
},
"ManagedPolicyArns": [
"arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
],
"Policies": [
{
"PolicyName": "rUploadCustomCfnNagRolePolicy0",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"s3:PutObject",
"s3:DeleteObject"
],
"Resource": [
{
"Fn::Sub": "${rCustomCFNNagRulesBucket.Arn}/*"
}
],
"Effect": "Allow"
},
{
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
}
],
"Tags": [
{
"Value": "SAM",
"Key": "lambda:createdBy"
},
{
"Value": {
"Fn::Sub": "${pProjectName}-cfnnag-upload-lambda"
},
"Key": "Name"
}
]
},
"Condition": "cCfnNagStyleRules"
}
```
I propose that Pseudo Parameters get used instead.

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.