Skip to content

Commit

Permalink
fixing linter issues introduced by rdk examples (#495)
Browse files Browse the repository at this point in the history
Authored-by: Javy de Koning
  • Loading branch information
javydekoning authored Aug 23, 2022
1 parent 8c8fc95 commit 5d3c8ec
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 156 deletions.
4 changes: 3 additions & 1 deletion .mega-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ FILEIO_REPORTER: false

JSON_PRETTIER_PRE_COMMANDS:
- command: npm install prettier-plugin-multiline-arrays@1.1.0
cwd: "workspace"
cwd: "workspace"

CLOUDFORMATION_CFN_LINT_FILE_EXTENSIONS: [".yml", ".yaml"]
2 changes: 1 addition & 1 deletion samples/sample-rdk-rules/buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ phases:
- aws s3 cp s3://$S3_BUCKET_NAME/adf-build/ adf-build/ --recursive --quiet
- pip install -r adf-build/requirements.txt -q
- python adf-build/generate_params.py

build:
commands:
- pip install rdk
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"Version": "1.0",
"Parameters": {
"RuleName": "EC2_CHECKS_TERMINIATION_PROTECTION_ADF",
"Description": "EC2_CHECKS_TERMINIATION_PROTECTION_ADF",
"SourceRuntime": "python3.8",
"CodeKey": "EC2_CHECKS_TERMINIATION_PROTECTION_ADFeu-central-1.zip",
"InputParameters": "{}",
"OptionalParameters": "{}",
"SourceEvents": "AWS::EC2::Instance",
"SourcePeriodic": "One_Hour"
},
"Tags": "[]"
}
"Version": "1.0",
"Parameters": {
"RuleName": "EC2_CHECKS_TERMINIATION_PROTECTION_ADF",
"Description": "EC2_CHECKS_TERMINIATION_PROTECTION_ADF",
"SourceRuntime": "python3.8",
"CodeKey": "EC2_CHECKS_TERMINIATION_PROTECTION_ADFeu-central-1.zip",
"InputParameters": "{}",
"OptionalParameters": "{}",
"SourceEvents": "AWS::EC2::Instance",
"SourcePeriodic": "One_Hour"
},
"Tags": "[]"
}
47 changes: 23 additions & 24 deletions samples/sample-rdk-rules/templates/lambda-function.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@

{
"Type": "AWS::Lambda::Function",
"DependsOn": "RuleNameStrippedLambdaRole",
"Properties": {
"FunctionName": "RDK-Rule-Function-RuleNameStripped",
"Code": {
"S3Bucket": {
"Ref": "SourceBucket"
},
"S3Key": "RuleName/RuleName.zip"
},
"Description": "Function for AWS Config Rule RuleName",
"Handler": "RuleName.lambda_handler",
"MemorySize": "256",
"Role": {
"Fn::GetAtt": [
"RuleNameStrippedLambdaRole",
"Arn"
]
},
"Runtime": "RuleRuntime",
"Timeout": "60",
"Tags": []
}
"Type": "AWS::Lambda::Function",
"DependsOn": "RuleNameStrippedLambdaRole",
"Properties": {
"FunctionName": "RDK-Rule-Function-RuleNameStripped",
"Code": {
"S3Bucket": {
"Ref": "SourceBucket"
},
"S3Key": "RuleName/RuleName.zip"
},
"Description": "Function for AWS Config Rule RuleName",
"Handler": "RuleName.lambda_handler",
"MemorySize": "256",
"Role": {
"Fn::GetAtt": [
"RuleNameStrippedLambdaRole",
"Arn"
]
},
"Runtime": "RuleRuntime",
"Timeout": "60",
"Tags": []
}
}
25 changes: 12 additions & 13 deletions samples/sample-rdk-rules/templates/lambda-permission.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@

{
"Type": "AWS::Lambda::Permission",
"DependsOn": "RuleNameStrippedLambdaFunction",
"Properties": {
"FunctionName": {
"Fn::GetAtt": [
"RuleNameStrippedLambdaFunction",
"Arn"
]
},
"Action": "lambda:InvokeFunction",
"Principal": "config.amazonaws.com"
}
"Type": "AWS::Lambda::Permission",
"DependsOn": "RuleNameStrippedLambdaFunction",
"Properties": {
"FunctionName": {
"Fn::GetAtt": [
"RuleNameStrippedLambdaFunction",
"Arn"
]
},
"Action": "lambda:InvokeFunction",
"Principal": "config.amazonaws.com"
}
}
147 changes: 70 additions & 77 deletions samples/sample-rdk-rules/templates/lambda-role.json
Original file line number Diff line number Diff line change
@@ -1,82 +1,75 @@

{
"Type": "AWS::IAM::Role",
"Properties": {
"Path": "/rdk/",
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowLambdaAssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
},
"Policies": [
{
"PolicyName": "ConfigRulePolicy",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
"Type": "AWS::IAM::Role",
"Properties": {
"Path": "/rdk/",
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowLambdaAssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
},
"Policies": [
{
"Sid": "1",
"Action": [
"s3:GetObject"
],
"Effect": "Allow",
"Resource": {
"Fn::Sub": "arn:aws:s3:::${SourceBucket}/${SourceBucketFolder}/*"
}
},
{
"Sid": "2",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:DescribeLogStreams"
],
"Effect": "Allow",
"Resource": "*"
},
{
"Sid": "3",
"Action": [
"config:PutEvaluations"
],
"Effect": "Allow",
"Resource": "*"
},
{
"Sid": "4",
"Action": [
"iam:List*",
"iam:Describe*",
"iam:Get*"
],
"Effect": "Allow",
"Resource": "*"
},
"PolicyName": "ConfigRulePolicy",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Sid": "1",
"Action": ["s3:GetObject"],
"Effect": "Allow",
"Resource": {
"Fn::Sub": "arn:aws:s3:::${SourceBucket}/${SourceBucketFolder}/*"
}
},
{
"Sid": "2",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:DescribeLogStreams"
],
"Effect": "Allow",
"Resource": "*"
},
{
"Sid": "3",
"Action": ["config:PutEvaluations"],
"Effect": "Allow",
"Resource": "*"
},
{
"Sid": "4",
"Action": [
"iam:List*",
"iam:Describe*",
"iam:Get*"
],
"Effect": "Allow",
"Resource": "*"
},
{
"Sid": "5",
"Action": ["sts:AssumeRole"],
"Effect": "Allow",
"Resource": "${ConfigRoleArnToAssume}"
}
]
}
}
],
"ManagedPolicyArns": [
{
"Sid": "5",
"Action": [
"sts:AssumeRole"
],
"Effect": "Allow",
"Resource": "${ConfigRoleArnToAssume}"
"Fn::Sub": "arn:aws:iam::aws:policy/ReadOnlyAccess"
}
]
}
}
],
"ManagedPolicyArns": [
{
"Fn::Sub": "arn:aws:iam::aws:policy/ReadOnlyAccess"
}
]
}
]
}
}
45 changes: 22 additions & 23 deletions samples/sample-rdk-rules/templates/parameters.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@

{
"SourceBucket": {
"Description": "Name of the S3 bucket that you have stored the rule zip files in.",
"Type": "String",
"MinLength": "1",
"MaxLength": "255"
},
"SourceBucketFolder": {
"Description": "Folder in the s3 bucket all the lambda function code stored",
"Type": "String",
"MinLength": "1",
"MaxLength": "255"
},
"LambdaAccountId": {
"Description": "Account ID that contains Lambda functions for Config Rules.",
"Type": "String",
"MinLength": "12",
"MaxLength": "12"
},
"ConfigRoleArnToAssume": {
"Description": "Lambda function required to assume this config role in target accounts to put evaluations",
"Type": "String"
}
"SourceBucket": {
"Description": "Name of the S3 bucket that you have stored the rule zip files in.",
"Type": "String",
"MinLength": "1",
"MaxLength": "255"
},
"SourceBucketFolder": {
"Description": "Folder in the s3 bucket all the lambda function code stored",
"Type": "String",
"MinLength": "1",
"MaxLength": "255"
},
"LambdaAccountId": {
"Description": "Account ID that contains Lambda functions for Config Rules.",
"Type": "String",
"MinLength": "12",
"MaxLength": "12"
},
"ConfigRoleArnToAssume": {
"Description": "Lambda function required to assume this config role in target accounts to put evaluations",
"Type": "String"
}
}
7 changes: 3 additions & 4 deletions samples/sample-rdk-rules/templates/skeleton.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "AWS CloudFormation template to create Lambda functions for backing custom AWS Config rules. You will be billed for the AWS resources used if you create a stack from this template.",
"Resources": {}
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "AWS CloudFormation template to create Lambda functions for backing custom AWS Config rules. You will be billed for the AWS resources used if you create a stack from this template.",
"Resources": {}
}

0 comments on commit 5d3c8ec

Please sign in to comment.