Skip to content

Commit da038b3

Browse files
authored
Merge pull request #436 from ericzbeard/main
Generating JSON
2 parents 20d9faa + 8f577cd commit da038b3

4 files changed

+37
-6
lines changed

Config/Config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@
245245
"ZipFile": "var aws = require('aws-sdk');\nvar config = new aws.ConfigService();\nvar ec2 = new aws.EC2();\nexports.handler = function(event, context) {\n var compliance = evaluateCompliance(event, function(compliance, event) {\n var configurationItem = JSON.parse(event.invokingEvent).configurationItem;\n var putEvaluationsRequest = {\n Evaluations: [{\n ComplianceResourceType: configurationItem.resourceType,\n ComplianceResourceId: configurationItem.resourceId,\n ComplianceType: compliance,\n OrderingTimestamp: configurationItem.configurationItemCaptureTime\n }],\n ResultToken: event.resultToken\n };\n config.putEvaluations(putEvaluationsRequest, function(err, data) {\n if (err) context.fail(err);\n else context.succeed(data);\n });\n });\n};\nfunction evaluateCompliance(event, doReturn) {\n var configurationItem = JSON.parse(event.invokingEvent).configurationItem;\n var status = configurationItem.configurationItemStatus;\n if (configurationItem.resourceType !== 'AWS::EC2::Volume' || event.eventLeftScope || (status !== 'OK' && status !== 'ResourceDiscovered'))\n doReturn('NOT_APPLICABLE', event);\n else ec2.describeVolumeAttribute({VolumeId: configurationItem.resourceId, Attribute: 'autoEnableIO'}, function(err, data) {\n if (err) context.fail(err);\n else if (data.AutoEnableIO.Value) doReturn('COMPLIANT', event);\n else doReturn('NON_COMPLIANT', event);\n });\n}\n"
246246
},
247247
"Handler": "index.handler",
248-
"Runtime": "nodejs16.x",
248+
"Runtime": "nodejs20.x",
249249
"Timeout": "30",
250250
"Role": {
251251
"Fn::GetAtt": [

RDS/RDS_MySQL_With_Read_Replica.json

+20-1
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,21 @@
113113
},
114114
"Condition": "IsEC2VPC"
115115
},
116+
"DBCredential": {
117+
"Type": "AWS::SecretsManager::Secret",
118+
"Properties": {
119+
"GenerateSecretString": {
120+
"PasswordLength": 16,
121+
"ExcludeCharacters": "\"@/\\",
122+
"RequireEachIncludedType": true
123+
}
124+
}
125+
},
116126
"MainDB": {
117127
"DeletionPolicy": "Snapshot",
118128
"UpdateReplacePolicy": "Snapshot",
119129
"Type": "AWS::RDS::DBInstance",
130+
"DependsOn": "DBCredential",
120131
"Properties": {
121132
"DBName": {
122133
"Ref": "DBName"
@@ -132,7 +143,9 @@
132143
"MasterUsername": {
133144
"Ref": "DBUser"
134145
},
135-
"MasterUserPassword": "{{resolve:secretsmanager:my-db-password}}",
146+
"MasterUserPassword": {
147+
"Fn::Sub": "{{resolve:secretsmanager:${DBCredential}}}"
148+
},
136149
"MultiAZ": {
137150
"Ref": "MultiAZ"
138151
},
@@ -194,6 +207,12 @@
194207
}
195208
},
196209
"Outputs": {
210+
"DBCredentialSecretNameArn": {
211+
"Description": "Name of the secret containing the database credential",
212+
"Value": {
213+
"Ref": "DBCredential"
214+
}
215+
},
197216
"EC2Platform": {
198217
"Description": "Platform in which this stack is deployed",
199218
"Value": {

RDS/RDS_PIOPS.json

+14-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,19 @@
1616
}
1717
},
1818
"Resources": {
19+
"DBCredential": {
20+
"Type": "AWS::SecretsManager::Secret",
21+
"Properties": {
22+
"GenerateSecretString": {
23+
"PasswordLength": 16,
24+
"ExcludeCharacters": "\"@/\\",
25+
"RequireEachIncludedType": true
26+
}
27+
}
28+
},
1929
"myDB": {
2030
"Type": "AWS::RDS::DBInstance",
31+
"DependsOn": "DBCredential",
2132
"Properties": {
2233
"AllocatedStorage": "100",
2334
"DBInstanceClass": "db.t3.small",
@@ -27,7 +38,9 @@
2738
"MasterUsername": {
2839
"Ref": "DBUser"
2940
},
30-
"MasterUserPassword": "{{resolve:secretsmanager:my-db-password}}",
41+
"MasterUserPassword": {
42+
"Fn::Sub": "{{resolve:secretsmanager:${DBCredential}}}"
43+
},
3144
"PubliclyAccessible": false,
3245
"StorageEncrypted": true
3346
}

RDS/RDS_with_DBParameterGroup.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,11 @@
6060
"MyRDSParamGroup": {
6161
"Type": "AWS::RDS::DBParameterGroup",
6262
"Properties": {
63-
"Family": "MySQL5.6",
63+
"Family": "MySQL8.0",
6464
"Description": "CloudFormation Sample Database Parameter Group",
6565
"Parameters": {
6666
"autocommit": "1",
67-
"general_log": "1",
68-
"old_passwords": "0"
67+
"general_log": "1"
6968
}
7069
}
7170
}

0 commit comments

Comments
 (0)