Skip to content

Commit

Permalink
Fix more cfn_nag issues
Browse files Browse the repository at this point in the history
  • Loading branch information
biffgaut committed Oct 6, 2021
1 parent 31472a6 commit 82783b8
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 54 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Description": "Integration Test for aws-route53-alb",
"Resources": {
"testroute53albtestroute53albzone04BEDFE6": {
"privateapistackprivateapistackzone3E5194E7": {
"Type": "AWS::Route53::HostedZone",
"Properties": {
"Name": "www.example.com.",
Expand All @@ -15,7 +15,7 @@
]
}
},
"testroute53albtestroute53albalb7C171F50": {
"privateapistackprivateapistackalb7242E759": {
"Type": "AWS::ElasticLoadBalancingV2::LoadBalancer",
"Properties": {
"LoadBalancerAttributes": [
Expand All @@ -30,7 +30,7 @@
{
"Key": "access_logs.s3.bucket",
"Value": {
"Ref": "testroute53albAC463A50"
"Ref": "privateapistack09C932BB"
}
},
{
Expand All @@ -42,7 +42,7 @@
"SecurityGroups": [
{
"Fn::GetAtt": [
"testroute53albtestroute53albalbSecurityGroupC3716E02",
"privateapistackprivateapistackalbSecurityGroup5A8A9725",
"GroupId"
]
}
Expand All @@ -61,14 +61,14 @@
"Type": "application"
},
"DependsOn": [
"testroute53albPolicy478FC0AF",
"testroute53albAC463A50"
"privateapistackPolicy98558170",
"privateapistack09C932BB"
]
},
"testroute53albtestroute53albalbSecurityGroupC3716E02": {
"privateapistackprivateapistackalbSecurityGroup5A8A9725": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Automatically created Security Group for ELB deployPrivateApitestroute53albtestroute53albalb1145D1AD",
"GroupDescription": "Automatically created Security Group for ELB deployPrivateApiprivateapistackprivateapistackalb5DF93E18",
"SecurityGroupEgress": [
{
"CidrIp": "255.255.255.255/32",
Expand All @@ -83,11 +83,21 @@
}
},
"DependsOn": [
"testroute53albPolicy478FC0AF",
"testroute53albAC463A50"
]
"privateapistackPolicy98558170",
"privateapistack09C932BB"
],
"Metadata": {
"cfn_nag": {
"rules_to_suppress": [
{
"id": "W29",
"reason": "CDK created rule that blocks all traffic."
}
]
}
}
},
"testroute53albAC463A50": {
"privateapistack09C932BB": {
"Type": "AWS::S3::Bucket",
"Properties": {
"BucketEncryption": {
Expand Down Expand Up @@ -122,11 +132,11 @@
}
}
},
"testroute53albPolicy478FC0AF": {
"privateapistackPolicy98558170": {
"Type": "AWS::S3::BucketPolicy",
"Properties": {
"Bucket": {
"Ref": "testroute53albAC463A50"
"Ref": "privateapistack09C932BB"
},
"PolicyDocument": {
"Statement": [
Expand All @@ -148,7 +158,7 @@
[
{
"Fn::GetAtt": [
"testroute53albAC463A50",
"privateapistack09C932BB",
"Arn"
]
},
Expand All @@ -158,7 +168,7 @@
},
{
"Fn::GetAtt": [
"testroute53albAC463A50",
"privateapistack09C932BB",
"Arn"
]
}
Expand Down Expand Up @@ -191,7 +201,7 @@
[
{
"Fn::GetAtt": [
"testroute53albAC463A50",
"privateapistack09C932BB",
"Arn"
]
},
Expand All @@ -209,7 +219,7 @@
}
}
},
"testroute53albtestroute53albaliasCCC6DDF3": {
"privateapistackprivateapistackalias54E3713F": {
"Type": "AWS::Route53::RecordSet",
"Properties": {
"Name": "www.example.com.",
Expand All @@ -222,7 +232,7 @@
"dualstack.",
{
"Fn::GetAtt": [
"testroute53albtestroute53albalb7C171F50",
"privateapistackprivateapistackalb7242E759",
"DNSName"
]
}
Expand All @@ -231,13 +241,13 @@
},
"HostedZoneId": {
"Fn::GetAtt": [
"testroute53albtestroute53albalb7C171F50",
"privateapistackprivateapistackalb7242E759",
"CanonicalHostedZoneID"
]
}
},
"HostedZoneId": {
"Ref": "testroute53albtestroute53albzone04BEDFE6"
"Ref": "privateapistackprivateapistackzone3E5194E7"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import { App, Stack, Aws } from "@aws-cdk/core";
import { Route53ToAlb, Route53ToAlbProps } from "../lib";
import { generateIntegStackName } from '@aws-solutions-constructs/core';
import * as defaults from '@aws-solutions-constructs/core';
import { CfnSecurityGroup } from "@aws-cdk/aws-ec2";

// Setup
const app = new App();
Expand All @@ -31,7 +33,10 @@ const props: Route53ToAlbProps = {
}
};

new Route53ToAlb(stack, 'test-route53-alb', props);
const testConstruct = new Route53ToAlb(stack, 'private-api-stack', props);

const newSecurityGroup = testConstruct.loadBalancer.connections.securityGroups[0].node.defaultChild as CfnSecurityGroup;
defaults.addCfnSuppressRules(newSecurityGroup, [{ id: 'W29', reason: 'CDK created rule that blocks all traffic.'}]);

// Synth
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -716,9 +716,19 @@
"VpcId": {
"Ref": "Vpc8378EB38"
}
},
"Metadata": {
"cfn_nag": {
"rules_to_suppress": [
{
"id": "W29",
"reason": "CDK created rule that blocks all traffic."
}
]
}
}
},
"testroute53albtestroute53albaliasCCC6DDF3": {
"publicapistackpublicapistackalias4096038C": {
"Type": "AWS::Route53::RecordSet",
"Properties": {
"Name": "www.test-example.com.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { ApplicationLoadBalancer } from "@aws-cdk/aws-elasticloadbalancingv2";
import { PublicHostedZone } from "@aws-cdk/aws-route53";
import { Route53ToAlb, Route53ToAlbProps } from "../lib";
import { generateIntegStackName } from '@aws-solutions-constructs/core';
import { CfnSecurityGroup } from "@aws-cdk/aws-ec2";

// Setup
const app = new App();
Expand Down Expand Up @@ -53,7 +54,10 @@ const props: Route53ToAlbProps = {
existingLoadBalancerObj: existingAlb,
};

new Route53ToAlb(stack, 'test-route53-alb', props);
const testConstruct = new Route53ToAlb(stack, 'public-api-stack', props);

const newSecurityGroup = testConstruct.loadBalancer.connections.securityGroups[0].node.defaultChild as CfnSecurityGroup;
defaults.addCfnSuppressRules(newSecurityGroup, [{ id: 'W29', reason: 'CDK created rule that blocks all traffic.'}]);

// Synth
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@
"Name": "www.test-example.com."
}
},
"testroute53albtestroute53albalb7C171F50": {
"newalbstacknewalbstackalb50B67E3E": {
"Type": "AWS::ElasticLoadBalancingV2::LoadBalancer",
"Properties": {
"LoadBalancerAttributes": [
Expand All @@ -673,7 +673,7 @@
{
"Key": "access_logs.s3.bucket",
"Value": {
"Ref": "testroute53albAC463A50"
"Ref": "newalbstackADB02838"
}
},
{
Expand All @@ -686,7 +686,7 @@
"SecurityGroups": [
{
"Fn::GetAtt": [
"testroute53albtestroute53albalbSecurityGroupC3716E02",
"newalbstacknewalbstackalbSecurityGroup7BBB827C",
"GroupId"
]
}
Expand All @@ -705,17 +705,17 @@
"Type": "application"
},
"DependsOn": [
"testroute53albPolicy478FC0AF",
"testroute53albAC463A50",
"newalbstackPolicyB7C2D898",
"newalbstackADB02838",
"VpcPublicSubnet1DefaultRoute3DA9E72A",
"VpcPublicSubnet2DefaultRoute97F91067",
"VpcPublicSubnet3DefaultRoute4697774F"
]
},
"testroute53albtestroute53albalbSecurityGroupC3716E02": {
"newalbstacknewalbstackalbSecurityGroup7BBB827C": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Automatically created Security Group for ELB deployPublicApiNewAlbtestroute53albtestroute53albalbC4C12C26",
"GroupDescription": "Automatically created Security Group for ELB deployPublicApiNewAlbnewalbstacknewalbstackalbC987D9E9",
"SecurityGroupEgress": [
{
"CidrIp": "255.255.255.255/32",
Expand All @@ -730,11 +730,21 @@
}
},
"DependsOn": [
"testroute53albPolicy478FC0AF",
"testroute53albAC463A50"
]
"newalbstackPolicyB7C2D898",
"newalbstackADB02838"
],
"Metadata": {
"cfn_nag": {
"rules_to_suppress": [
{
"id": "W29",
"reason": "CDK created rule that blocks all traffic."
}
]
}
}
},
"testroute53albAC463A50": {
"newalbstackADB02838": {
"Type": "AWS::S3::Bucket",
"Properties": {
"BucketEncryption": {
Expand Down Expand Up @@ -769,11 +779,11 @@
}
}
},
"testroute53albPolicy478FC0AF": {
"newalbstackPolicyB7C2D898": {
"Type": "AWS::S3::BucketPolicy",
"Properties": {
"Bucket": {
"Ref": "testroute53albAC463A50"
"Ref": "newalbstackADB02838"
},
"PolicyDocument": {
"Statement": [
Expand All @@ -795,7 +805,7 @@
[
{
"Fn::GetAtt": [
"testroute53albAC463A50",
"newalbstackADB02838",
"Arn"
]
},
Expand All @@ -805,7 +815,7 @@
},
{
"Fn::GetAtt": [
"testroute53albAC463A50",
"newalbstackADB02838",
"Arn"
]
}
Expand Down Expand Up @@ -838,7 +848,7 @@
[
{
"Fn::GetAtt": [
"testroute53albAC463A50",
"newalbstackADB02838",
"Arn"
]
},
Expand All @@ -856,7 +866,7 @@
}
}
},
"testroute53albtestroute53albaliasCCC6DDF3": {
"newalbstacknewalbstackalias05E0DF53": {
"Type": "AWS::Route53::RecordSet",
"Properties": {
"Name": "www.test-example.com.",
Expand All @@ -869,7 +879,7 @@
"dualstack.",
{
"Fn::GetAtt": [
"testroute53albtestroute53albalb7C171F50",
"newalbstacknewalbstackalb50B67E3E",
"DNSName"
]
}
Expand All @@ -878,7 +888,7 @@
},
"HostedZoneId": {
"Fn::GetAtt": [
"testroute53albtestroute53albalb7C171F50",
"newalbstacknewalbstackalb50B67E3E",
"CanonicalHostedZoneID"
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { App, Stack, Aws } from "@aws-cdk/core";
import * as defaults from '@aws-solutions-constructs/core';
import { PublicHostedZone } from "@aws-cdk/aws-route53";
import { Route53ToAlb, Route53ToAlbProps } from "../lib";
import { CfnSecurityGroup } from "@aws-cdk/aws-ec2";

// Setup
const app = new App();
Expand Down Expand Up @@ -47,7 +48,10 @@ const props: Route53ToAlbProps = {
}
};

new Route53ToAlb(stack, 'test-route53-alb', props);
const testConstruct = new Route53ToAlb(stack, 'new-alb-stack', props);

const newSecurityGroup = testConstruct.loadBalancer.connections.securityGroups[0].node.defaultChild as CfnSecurityGroup;
defaults.addCfnSuppressRules(newSecurityGroup, [{ id: 'W29', reason: 'CDK created rule that blocks all traffic.'}]);

// Synth
app.synth();
Loading

0 comments on commit 82783b8

Please sign in to comment.