From 3f3a84898b059e9b9efe5c12515366b0c3200de5 Mon Sep 17 00:00:00 2001 From: Jane Chen Date: Mon, 27 Nov 2023 13:35:56 -0500 Subject: [PATCH 1/6] feat(appconfig): support for composite alarms --- .../@aws-cdk/aws-appconfig-alpha/README.md | 2 + .../aws-appconfig-alpha/lib/environment.ts | 26 +- .../test/environment.test.ts | 181 +++++++++++++- .../aws-appconfig-environment.assets.json | 4 +- .../aws-appconfig-environment.template.json | 154 ++++++++++++ .../manifest.json | 38 ++- .../integ.environment.js.snapshot/tree.json | 236 ++++++++++++++++++ .../test/integ.environment.ts | 23 +- 8 files changed, 654 insertions(+), 10 deletions(-) diff --git a/packages/@aws-cdk/aws-appconfig-alpha/README.md b/packages/@aws-cdk/aws-appconfig-alpha/README.md index e5247dd5c7e59..14c506a5fb90e 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/README.md +++ b/packages/@aws-cdk/aws-appconfig-alpha/README.md @@ -326,11 +326,13 @@ Basic environment with monitors: ```ts declare const application: appconfig.Application; declare const alarm: cloudwatch.Alarm; +declare const compositeAlarm: cloudwatch.CompositeAlarm; new appconfig.Environment(this, 'MyEnvironment', { application, monitors: [ appconfig.Monitor.fromCloudWatchAlarm(alarm), + appconfig.Monitor.fromCloudWatchAlarm(compositeAlarm), ], }); ``` diff --git a/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts b/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts index cbe4c1ebbebb7..0ba72ac8b3ee9 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts @@ -246,7 +246,7 @@ export class Environment extends EnvironmentBase { return { alarmArn: monitor.alarmArn, ...(monitor.monitorType === MonitorType.CLOUDWATCH - ? { alarmRoleArn: monitor.alarmRoleArn || this.createAlarmRole(monitor.alarmArn, index).roleArn } + ? { alarmRoleArn: monitor.alarmRoleArn || this.createAlarmRole(monitor, index).roleArn } : { alarmRoleArn: monitor.alarmRoleArn }), }; }), @@ -264,7 +264,21 @@ export class Environment extends EnvironmentBase { this.application.addExistingEnvironment(this); } - private createAlarmRole(alarmArn: string, index: number): iam.IRole { + private createAlarmRole(monitor: Monitor, index: number): iam.IRole { + const roleHash = monitor.isCompositeAlarm ? 5 : index; + const logicalId = `Role${roleHash}`; + const existingRole = this.node.tryFindChild(logicalId) as iam.IRole; + if (existingRole) { + return existingRole; + } + const alarmArn = monitor.isCompositeAlarm + ? this.stack.formatArn({ + service: 'cloudwatch', + resource: 'alarm', + resourceName: '*', + arnFormat: ArnFormat.COLON_RESOURCE_NAME, + }) + : monitor.alarmArn; const policy = new iam.PolicyStatement({ effect: iam.Effect.ALLOW, actions: ['cloudwatch:DescribeAlarms'], @@ -273,7 +287,7 @@ export class Environment extends EnvironmentBase { const document = new iam.PolicyDocument({ statements: [policy], }); - const role = new iam.Role(this, `Role${index}`, { + const role = new iam.Role(this, logicalId, { roleName: PhysicalName.GENERATE_IF_NEEDED, assumedBy: new iam.ServicePrincipal('appconfig.amazonaws.com'), inlinePolicies: { @@ -305,6 +319,7 @@ export abstract class Monitor { alarmArn: alarm.alarmArn, alarmRoleArn: alarmRole?.roleArn, monitorType: MonitorType.CLOUDWATCH, + isCompositeAlarm: alarm instanceof cloudwatch.CompositeAlarm, }; } @@ -335,6 +350,11 @@ export abstract class Monitor { * The IAM role ARN for AWS AppConfig to view the alarm state. */ public abstract readonly alarmRoleArn?: string; + + /** + * Indicates whether a CloudWatch alarm is a composite alarm. + */ + public abstract readonly isCompositeAlarm?: boolean; } export interface IEnvironment extends IResource { diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/environment.test.ts b/packages/@aws-cdk/aws-appconfig-alpha/test/environment.test.ts index a7426b2e2e3e7..f4941d242aa10 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/environment.test.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/environment.test.ts @@ -1,7 +1,7 @@ import * as cdk from 'aws-cdk-lib'; import { App } from 'aws-cdk-lib'; import { Template } from 'aws-cdk-lib/assertions'; -import { Alarm, Metric } from 'aws-cdk-lib/aws-cloudwatch'; +import { Alarm, CompositeAlarm, Metric } from 'aws-cdk-lib/aws-cloudwatch'; import * as iam from 'aws-cdk-lib/aws-iam'; import { Application, Environment, Monitor } from '../lib'; @@ -230,6 +230,185 @@ describe('environment', () => { }); }); + test('environment with composite alarm', () => { + const stack = new cdk.Stack(); + const app = new Application(stack, 'MyAppConfig'); + const alarm = new Alarm(stack, 'Alarm', { + threshold: 5, + evaluationPeriods: 5, + metric: new Metric( + { + namespace: 'aws', + metricName: 'myMetric', + }, + ), + }); + const compositeAlarm = new CompositeAlarm(stack, 'MyCompositeAlarm', { + alarmRule: alarm, + }); + const env = new Environment(stack, 'MyEnvironment', { + name: 'TestEnv', + application: app, + monitors: [ + Monitor.fromCloudWatchAlarm(compositeAlarm), + ], + }); + + expect(env).toBeDefined(); + Template.fromStack(stack).resourceCountIs('AWS::CloudWatch::Alarm', 1); + Template.fromStack(stack).resourceCountIs('AWS::CloudWatch::CompositeAlarm', 1); + Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::Environment', { + Name: 'TestEnv', + ApplicationId: { + Ref: 'MyAppConfigB4B63E75', + }, + Monitors: [ + { + AlarmArn: { + 'Fn::GetAtt': [ + 'MyCompositeAlarm0F045229', + 'Arn', + ], + }, + AlarmRoleArn: { + 'Fn::GetAtt': [ + 'MyEnvironmentRole51BFC2F05', + 'Arn', + ], + }, + }, + ], + }); + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Role', { + Policies: [ + { + PolicyDocument: { + Statement: [ + { + Effect: iam.Effect.ALLOW, + Resource: { + 'Fn::Join': [ + '', + [ + 'arn:', + { Ref: 'AWS::Partition' }, + ':cloudwatch:', + { Ref: 'AWS::Region' }, + ':', + { Ref: 'AWS::AccountId' }, + ':alarm:*', + ], + ], + }, + Action: 'cloudwatch:DescribeAlarms', + }, + ], + }, + PolicyName: 'AllowAppConfigMonitorAlarmPolicy', + }, + ], + }); + }); + + test('environment with two composite alarms', () => { + const stack = new cdk.Stack(); + const app = new Application(stack, 'MyAppConfig'); + const alarm = new Alarm(stack, 'Alarm', { + threshold: 5, + evaluationPeriods: 5, + metric: new Metric( + { + namespace: 'aws', + metricName: 'myMetric', + }, + ), + }); + const compositeAlarm1 = new CompositeAlarm(stack, 'MyCompositeAlarm1', { + alarmRule: alarm, + }); + const compositeAlarm2 = new CompositeAlarm(stack, 'MyCompositeAlarm2', { + alarmRule: alarm, + }); + const env = new Environment(stack, 'MyEnvironment', { + name: 'TestEnv', + application: app, + monitors: [ + Monitor.fromCloudWatchAlarm(compositeAlarm1), + Monitor.fromCloudWatchAlarm(compositeAlarm2), + ], + }); + + expect(env).toBeDefined(); + Template.fromStack(stack).resourceCountIs('AWS::CloudWatch::Alarm', 1); + Template.fromStack(stack).resourceCountIs('AWS::CloudWatch::CompositeAlarm', 2); + Template.fromStack(stack).resourceCountIs('AWS::IAM::Role', 1); + Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::Environment', { + Name: 'TestEnv', + ApplicationId: { + Ref: 'MyAppConfigB4B63E75', + }, + Monitors: [ + { + AlarmArn: { + 'Fn::GetAtt': [ + 'MyCompositeAlarm159A950D0', + 'Arn', + ], + }, + AlarmRoleArn: { + 'Fn::GetAtt': [ + 'MyEnvironmentRole51BFC2F05', + 'Arn', + ], + }, + }, + { + AlarmArn: { + 'Fn::GetAtt': [ + 'MyCompositeAlarm2195BFA48', + 'Arn', + ], + }, + AlarmRoleArn: { + 'Fn::GetAtt': [ + 'MyEnvironmentRole51BFC2F05', + 'Arn', + ], + }, + }, + ], + }); + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Role', { + Policies: [ + { + PolicyDocument: { + Statement: [ + { + Effect: iam.Effect.ALLOW, + Resource: { + 'Fn::Join': [ + '', + [ + 'arn:', + { Ref: 'AWS::Partition' }, + ':cloudwatch:', + { Ref: 'AWS::Region' }, + ':', + { Ref: 'AWS::AccountId' }, + ':alarm:*', + ], + ], + }, + Action: 'cloudwatch:DescribeAlarms', + }, + ], + }, + PolicyName: 'AllowAppConfigMonitorAlarmPolicy', + }, + ], + }); + }); + test('environment with monitors with two alarms', () => { const stack = new cdk.Stack(); const app = new Application(stack, 'MyAppConfig'); diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.assets.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.assets.json index 89f92e7bd5dc4..00bb471291c02 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.assets.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.assets.json @@ -1,7 +1,7 @@ { "version": "34.0.0", "files": { - "ea755ac1ccc8e2c8816cf7e0a2b3789e472a166174037cb50eb45ec4ed621ba4": { + "4acf8ce55e047ee524070ef3dbc29548495dfbd975bb2ec9927da4e529199c8f": { "source": { "path": "aws-appconfig-environment.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "ea755ac1ccc8e2c8816cf7e0a2b3789e472a166174037cb50eb45ec4ed621ba4.json", + "objectKey": "4acf8ce55e047ee524070ef3dbc29548495dfbd975bb2ec9927da4e529199c8f.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.template.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.template.json index c3951447345b9..2056e22fdcb17 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.template.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.template.json @@ -35,6 +35,27 @@ } } }, + "MyCompositeAlarm0F045229": { + "Type": "AWS::CloudWatch::CompositeAlarm", + "Properties": { + "AlarmName": "awsappconfigenvironmentMyCompositeAlarm730A7A48", + "AlarmRule": { + "Fn::Join": [ + "", + [ + "ALARM(\"", + { + "Fn::GetAtt": [ + "MyAlarm696658B6", + "Arn" + ] + }, + "\")" + ] + ] + } + } + }, "MyEnvironmentRole01C8C013F": { "Type": "AWS::IAM::Role", "Properties": { @@ -72,6 +93,57 @@ ] } }, + "MyEnvironmentRole51BFC2F05": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "appconfig.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "Policies": [ + { + "PolicyDocument": { + "Statement": [ + { + "Action": "cloudwatch:DescribeAlarms", + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":cloudwatch:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":alarm:*" + ] + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "AllowAppConfigMonitorAlarmPolicy" + } + ] + } + }, "MyEnvironment465E4DEA": { "Type": "AWS::AppConfig::Environment", "Properties": { @@ -107,10 +179,92 @@ "Arn" ] } + }, + { + "AlarmArn": { + "Fn::GetAtt": [ + "MyCompositeAlarm0F045229", + "Arn" + ] + }, + "AlarmRoleArn": { + "Fn::GetAtt": [ + "MyEnvironmentRole51BFC2F05", + "Arn" + ] + } } ], "Name": "awsappconfigenvironment-MyEnvironment-C8813182" } + }, + "MyDeploymentStrategy60D31FB0": { + "Type": "AWS::AppConfig::DeploymentStrategy", + "Properties": { + "DeploymentDurationInMinutes": 1, + "FinalBakeTimeInMinutes": 1, + "GrowthFactor": 50, + "GrowthType": "LINEAR", + "Name": "awsappconfigenvironment-MyDeploymentStrategy-28486041", + "ReplicateTo": "NONE" + } + }, + "MyHostedConfigConfigurationProfile2E1A2BBC": { + "Type": "AWS::AppConfig::ConfigurationProfile", + "Properties": { + "ApplicationId": { + "Ref": "MyApplicationForEnv1F597ED9" + }, + "LocationUri": "hosted", + "Name": "awsappconfigenvironment-MyHostedConfig-26BB3558" + }, + "DependsOn": [ + "MyAlarm696658B6", + "MyCompositeAlarm0F045229" + ] + }, + "MyHostedConfig51D3877D": { + "Type": "AWS::AppConfig::HostedConfigurationVersion", + "Properties": { + "ApplicationId": { + "Ref": "MyApplicationForEnv1F597ED9" + }, + "ConfigurationProfileId": { + "Ref": "MyHostedConfigConfigurationProfile2E1A2BBC" + }, + "Content": "config content", + "ContentType": "text/plain" + }, + "DependsOn": [ + "MyAlarm696658B6", + "MyCompositeAlarm0F045229" + ], + "UpdateReplacePolicy": "Retain", + "DeletionPolicy": "Retain" + }, + "MyHostedConfigDeployment992941D06B01E": { + "Type": "AWS::AppConfig::Deployment", + "Properties": { + "ApplicationId": { + "Ref": "MyApplicationForEnv1F597ED9" + }, + "ConfigurationProfileId": { + "Ref": "MyHostedConfigConfigurationProfile2E1A2BBC" + }, + "ConfigurationVersion": { + "Ref": "MyHostedConfig51D3877D" + }, + "DeploymentStrategyId": { + "Ref": "MyDeploymentStrategy60D31FB0" + }, + "EnvironmentId": { + "Ref": "MyEnvironment465E4DEA" + } + }, + "DependsOn": [ + "MyAlarm696658B6", + "MyCompositeAlarm0F045229" + ] } }, "Parameters": { diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/manifest.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/manifest.json index 4c038cd5bcd81..ad09565da8609 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/manifest.json @@ -18,7 +18,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/ea755ac1ccc8e2c8816cf7e0a2b3789e472a166174037cb50eb45ec4ed621ba4.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/4acf8ce55e047ee524070ef3dbc29548495dfbd975bb2ec9927da4e529199c8f.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -52,18 +52,54 @@ "data": "MyRoleF48FFE04" } ], + "/aws-appconfig-environment/MyCompositeAlarm/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyCompositeAlarm0F045229" + } + ], "/aws-appconfig-environment/MyEnvironment/Role0/Resource": [ { "type": "aws:cdk:logicalId", "data": "MyEnvironmentRole01C8C013F" } ], + "/aws-appconfig-environment/MyEnvironment/Role5/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyEnvironmentRole51BFC2F05" + } + ], "/aws-appconfig-environment/MyEnvironment/Resource": [ { "type": "aws:cdk:logicalId", "data": "MyEnvironment465E4DEA" } ], + "/aws-appconfig-environment/MyDeploymentStrategy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyDeploymentStrategy60D31FB0" + } + ], + "/aws-appconfig-environment/MyHostedConfig/ConfigurationProfile": [ + { + "type": "aws:cdk:logicalId", + "data": "MyHostedConfigConfigurationProfile2E1A2BBC" + } + ], + "/aws-appconfig-environment/MyHostedConfig/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyHostedConfig51D3877D" + } + ], + "/aws-appconfig-environment/MyHostedConfig/Deployment99294": [ + { + "type": "aws:cdk:logicalId", + "data": "MyHostedConfigDeployment992941D06B01E" + } + ], "/aws-appconfig-environment/BootstrapVersion": [ { "type": "aws:cdk:logicalId", diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/tree.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/tree.json index 9b1d723134bbf..4051902e94c08 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/tree.json @@ -105,6 +105,45 @@ "version": "0.0.0" } }, + "MyCompositeAlarm": { + "id": "MyCompositeAlarm", + "path": "aws-appconfig-environment/MyCompositeAlarm", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-appconfig-environment/MyCompositeAlarm/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::CloudWatch::CompositeAlarm", + "aws:cdk:cloudformation:props": { + "alarmName": "awsappconfigenvironmentMyCompositeAlarm730A7A48", + "alarmRule": { + "Fn::Join": [ + "", + [ + "ALARM(\"", + { + "Fn::GetAtt": [ + "MyAlarm696658B6", + "Arn" + ] + }, + "\")" + ] + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_cloudwatch.CfnCompositeAlarm", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_cloudwatch.CompositeAlarm", + "version": "0.0.0" + } + }, "MyEnvironment": { "id": "MyEnvironment", "path": "aws-appconfig-environment/MyEnvironment", @@ -172,6 +211,83 @@ "version": "0.0.0" } }, + "Role5": { + "id": "Role5", + "path": "aws-appconfig-environment/MyEnvironment/Role5", + "children": { + "ImportRole5": { + "id": "ImportRole5", + "path": "aws-appconfig-environment/MyEnvironment/Role5/ImportRole5", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-appconfig-environment/MyEnvironment/Role5/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "appconfig.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "policies": [ + { + "policyName": "AllowAppConfigMonitorAlarmPolicy", + "policyDocument": { + "Statement": [ + { + "Action": "cloudwatch:DescribeAlarms", + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":cloudwatch:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":alarm:*" + ] + ] + } + } + ], + "Version": "2012-10-17" + } + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, "Resource": { "id": "Resource", "path": "aws-appconfig-environment/MyEnvironment/Resource", @@ -210,6 +326,20 @@ "Arn" ] } + }, + { + "alarmArn": { + "Fn::GetAtt": [ + "MyCompositeAlarm0F045229", + "Arn" + ] + }, + "alarmRoleArn": { + "Fn::GetAtt": [ + "MyEnvironmentRole51BFC2F05", + "Arn" + ] + } } ], "name": "awsappconfigenvironment-MyEnvironment-C8813182" @@ -226,6 +356,112 @@ "version": "0.0.0" } }, + "MyDeploymentStrategy": { + "id": "MyDeploymentStrategy", + "path": "aws-appconfig-environment/MyDeploymentStrategy", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-appconfig-environment/MyDeploymentStrategy/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::AppConfig::DeploymentStrategy", + "aws:cdk:cloudformation:props": { + "deploymentDurationInMinutes": 1, + "finalBakeTimeInMinutes": 1, + "growthFactor": 50, + "growthType": "LINEAR", + "name": "awsappconfigenvironment-MyDeploymentStrategy-28486041", + "replicateTo": "NONE" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_appconfig.CfnDeploymentStrategy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-appconfig-alpha.DeploymentStrategy", + "version": "0.0.0" + } + }, + "MyHostedConfig": { + "id": "MyHostedConfig", + "path": "aws-appconfig-environment/MyHostedConfig", + "children": { + "ConfigurationProfile": { + "id": "ConfigurationProfile", + "path": "aws-appconfig-environment/MyHostedConfig/ConfigurationProfile", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::AppConfig::ConfigurationProfile", + "aws:cdk:cloudformation:props": { + "applicationId": { + "Ref": "MyApplicationForEnv1F597ED9" + }, + "locationUri": "hosted", + "name": "awsappconfigenvironment-MyHostedConfig-26BB3558" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_appconfig.CfnConfigurationProfile", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-appconfig-environment/MyHostedConfig/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::AppConfig::HostedConfigurationVersion", + "aws:cdk:cloudformation:props": { + "applicationId": { + "Ref": "MyApplicationForEnv1F597ED9" + }, + "configurationProfileId": { + "Ref": "MyHostedConfigConfigurationProfile2E1A2BBC" + }, + "content": "config content", + "contentType": "text/plain" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_appconfig.CfnHostedConfigurationVersion", + "version": "0.0.0" + } + }, + "Deployment99294": { + "id": "Deployment99294", + "path": "aws-appconfig-environment/MyHostedConfig/Deployment99294", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::AppConfig::Deployment", + "aws:cdk:cloudformation:props": { + "applicationId": { + "Ref": "MyApplicationForEnv1F597ED9" + }, + "configurationProfileId": { + "Ref": "MyHostedConfigConfigurationProfile2E1A2BBC" + }, + "configurationVersion": { + "Ref": "MyHostedConfig51D3877D" + }, + "deploymentStrategyId": { + "Ref": "MyDeploymentStrategy60D31FB0" + }, + "environmentId": { + "Ref": "MyEnvironment465E4DEA" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_appconfig.CfnDeployment", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-appconfig-alpha.HostedConfiguration", + "version": "0.0.0" + } + }, "BootstrapVersion": { "id": "BootstrapVersion", "path": "aws-appconfig-environment/BootstrapVersion", diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.ts b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.ts index 3716997e2253e..7bbee64b83aec 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.ts @@ -1,7 +1,7 @@ import { IntegTest } from '@aws-cdk/integ-tests-alpha'; import { App, Stack } from 'aws-cdk-lib'; -import { Application, Environment, Monitor } from '../lib'; -import { Alarm, Metric } from 'aws-cdk-lib/aws-cloudwatch'; +import { Application, ConfigurationContent, DeploymentStrategy, Environment, HostedConfiguration, Monitor, RolloutStrategy } from '../lib'; +import { Alarm, CompositeAlarm, Metric } from 'aws-cdk-lib/aws-cloudwatch'; import { Role, ServicePrincipal } from 'aws-cdk-lib/aws-iam'; const app = new App(); @@ -23,9 +23,12 @@ const alarm = new Alarm(stack, 'MyAlarm', { const role = new Role(stack, 'MyRole', { assumedBy: new ServicePrincipal('appconfig.amazonaws.com'), }); +const compositeAlarm = new CompositeAlarm(stack, 'MyCompositeAlarm', { + alarmRule: alarm, +}); // create environment with all props defined -new Environment(stack, 'MyEnvironment', { +const env = new Environment(stack, 'MyEnvironment', { application: appForEnv, description: 'This is the environment for integ testing', monitors: [ @@ -34,9 +37,23 @@ new Environment(stack, 'MyEnvironment', { alarmArn: alarm.alarmArn, alarmRoleArn: role.roleArn, }), + Monitor.fromCloudWatchAlarm(compositeAlarm), ], }); +// try to deploy to that environment to make sure everything is +// configured properly +const config = new HostedConfiguration(stack, 'MyHostedConfig', { + content: ConfigurationContent.fromInlineText('config content'), + deploymentStrategy: new DeploymentStrategy(stack, 'MyDeploymentStrategy', { + rolloutStrategy: RolloutStrategy.LINEAR_50_PERCENT_EVERY_30_SECONDS, + }), + application: appForEnv, + deployTo: [env], +}); + +config.node.addDependency(alarm, compositeAlarm); + new IntegTest(app, 'appconfig-environment', { testCases: [stack], }); From cb814f03edf8caed4586f25bc853c9741fce67d0 Mon Sep 17 00:00:00 2001 From: Jane Chen Date: Mon, 27 Nov 2023 13:35:56 -0500 Subject: [PATCH 2/6] feat(appconfig): support for composite alarms --- .../test/integ.environment.ts | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.ts b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.ts index 7bbee64b83aec..bce1591e70ba8 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.ts @@ -1,6 +1,6 @@ import { IntegTest } from '@aws-cdk/integ-tests-alpha'; import { App, Stack } from 'aws-cdk-lib'; -import { Application, ConfigurationContent, DeploymentStrategy, Environment, HostedConfiguration, Monitor, RolloutStrategy } from '../lib'; +import { Application, Environment, Monitor } from '../lib'; import { Alarm, CompositeAlarm, Metric } from 'aws-cdk-lib/aws-cloudwatch'; import { Role, ServicePrincipal } from 'aws-cdk-lib/aws-iam'; @@ -28,7 +28,7 @@ const compositeAlarm = new CompositeAlarm(stack, 'MyCompositeAlarm', { }); // create environment with all props defined -const env = new Environment(stack, 'MyEnvironment', { +new Environment(stack, 'MyEnvironment', { application: appForEnv, description: 'This is the environment for integ testing', monitors: [ @@ -41,19 +41,6 @@ const env = new Environment(stack, 'MyEnvironment', { ], }); -// try to deploy to that environment to make sure everything is -// configured properly -const config = new HostedConfiguration(stack, 'MyHostedConfig', { - content: ConfigurationContent.fromInlineText('config content'), - deploymentStrategy: new DeploymentStrategy(stack, 'MyDeploymentStrategy', { - rolloutStrategy: RolloutStrategy.LINEAR_50_PERCENT_EVERY_30_SECONDS, - }), - application: appForEnv, - deployTo: [env], -}); - -config.node.addDependency(alarm, compositeAlarm); - new IntegTest(app, 'appconfig-environment', { testCases: [stack], }); From 38082c90e94c64e56d65ed515c25804e8eeadf3e Mon Sep 17 00:00:00 2001 From: Jane Chen Date: Mon, 27 Nov 2023 13:35:56 -0500 Subject: [PATCH 3/6] feat(appconfig): support for composite alarms --- .../aws-appconfig-environment.template.json | 68 ------------------- 1 file changed, 68 deletions(-) diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.template.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.template.json index 2056e22fdcb17..1fb7d8bde2b7b 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.template.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.template.json @@ -197,74 +197,6 @@ ], "Name": "awsappconfigenvironment-MyEnvironment-C8813182" } - }, - "MyDeploymentStrategy60D31FB0": { - "Type": "AWS::AppConfig::DeploymentStrategy", - "Properties": { - "DeploymentDurationInMinutes": 1, - "FinalBakeTimeInMinutes": 1, - "GrowthFactor": 50, - "GrowthType": "LINEAR", - "Name": "awsappconfigenvironment-MyDeploymentStrategy-28486041", - "ReplicateTo": "NONE" - } - }, - "MyHostedConfigConfigurationProfile2E1A2BBC": { - "Type": "AWS::AppConfig::ConfigurationProfile", - "Properties": { - "ApplicationId": { - "Ref": "MyApplicationForEnv1F597ED9" - }, - "LocationUri": "hosted", - "Name": "awsappconfigenvironment-MyHostedConfig-26BB3558" - }, - "DependsOn": [ - "MyAlarm696658B6", - "MyCompositeAlarm0F045229" - ] - }, - "MyHostedConfig51D3877D": { - "Type": "AWS::AppConfig::HostedConfigurationVersion", - "Properties": { - "ApplicationId": { - "Ref": "MyApplicationForEnv1F597ED9" - }, - "ConfigurationProfileId": { - "Ref": "MyHostedConfigConfigurationProfile2E1A2BBC" - }, - "Content": "config content", - "ContentType": "text/plain" - }, - "DependsOn": [ - "MyAlarm696658B6", - "MyCompositeAlarm0F045229" - ], - "UpdateReplacePolicy": "Retain", - "DeletionPolicy": "Retain" - }, - "MyHostedConfigDeployment992941D06B01E": { - "Type": "AWS::AppConfig::Deployment", - "Properties": { - "ApplicationId": { - "Ref": "MyApplicationForEnv1F597ED9" - }, - "ConfigurationProfileId": { - "Ref": "MyHostedConfigConfigurationProfile2E1A2BBC" - }, - "ConfigurationVersion": { - "Ref": "MyHostedConfig51D3877D" - }, - "DeploymentStrategyId": { - "Ref": "MyDeploymentStrategy60D31FB0" - }, - "EnvironmentId": { - "Ref": "MyEnvironment465E4DEA" - } - }, - "DependsOn": [ - "MyAlarm696658B6", - "MyCompositeAlarm0F045229" - ] } }, "Parameters": { From 1e803077a774e61df8805dbb3b4b23a6a9ee7b47 Mon Sep 17 00:00:00 2001 From: Jane Chen <125300057+chenjane-dev@users.noreply.github.com> Date: Thu, 30 Nov 2023 10:29:41 -0500 Subject: [PATCH 4/6] Update packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts Co-authored-by: Luca Pizzini --- packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts b/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts index fd0a813618c07..70109132b7443 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts @@ -275,8 +275,7 @@ export class Environment extends EnvironmentBase { } private createAlarmRole(monitor: Monitor, index: number): iam.IRole { - const roleHash = monitor.isCompositeAlarm ? 5 : index; - const logicalId = `Role${roleHash}`; + const logicalId = monitor.isCompositeAlarm ? 'RoleCompositeAlarm' : `Role${index}`; const existingRole = this.node.tryFindChild(logicalId) as iam.IRole; if (existingRole) { return existingRole; From 2ac3e0e7bfae3b54862b6b6b1127ac87c022a79a Mon Sep 17 00:00:00 2001 From: Jane Chen <125300057+chenjane-dev@users.noreply.github.com> Date: Thu, 30 Nov 2023 10:29:41 -0500 Subject: [PATCH 5/6] Update packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts Co-authored-by: Luca Pizzini --- .../test/environment.test.ts | 6 +- .../aws-appconfig-environment.assets.json | 4 +- .../aws-appconfig-environment.template.json | 86 ------- .../manifest.json | 38 +-- .../integ.environment.js.snapshot/tree.json | 236 ------------------ 5 files changed, 6 insertions(+), 364 deletions(-) diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/environment.test.ts b/packages/@aws-cdk/aws-appconfig-alpha/test/environment.test.ts index f4941d242aa10..9c6dd7c7f3e4b 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/environment.test.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/environment.test.ts @@ -272,7 +272,7 @@ describe('environment', () => { }, AlarmRoleArn: { 'Fn::GetAtt': [ - 'MyEnvironmentRole51BFC2F05', + 'MyEnvironmentRoleCompositeAlarm8C2A0542', 'Arn', ], }, @@ -357,7 +357,7 @@ describe('environment', () => { }, AlarmRoleArn: { 'Fn::GetAtt': [ - 'MyEnvironmentRole51BFC2F05', + 'MyEnvironmentRoleCompositeAlarm8C2A0542', 'Arn', ], }, @@ -371,7 +371,7 @@ describe('environment', () => { }, AlarmRoleArn: { 'Fn::GetAtt': [ - 'MyEnvironmentRole51BFC2F05', + 'MyEnvironmentRoleCompositeAlarm8C2A0542', 'Arn', ], }, diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.assets.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.assets.json index 00bb471291c02..89f92e7bd5dc4 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.assets.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.assets.json @@ -1,7 +1,7 @@ { "version": "34.0.0", "files": { - "4acf8ce55e047ee524070ef3dbc29548495dfbd975bb2ec9927da4e529199c8f": { + "ea755ac1ccc8e2c8816cf7e0a2b3789e472a166174037cb50eb45ec4ed621ba4": { "source": { "path": "aws-appconfig-environment.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "4acf8ce55e047ee524070ef3dbc29548495dfbd975bb2ec9927da4e529199c8f.json", + "objectKey": "ea755ac1ccc8e2c8816cf7e0a2b3789e472a166174037cb50eb45ec4ed621ba4.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.template.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.template.json index 1fb7d8bde2b7b..c3951447345b9 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.template.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.template.json @@ -35,27 +35,6 @@ } } }, - "MyCompositeAlarm0F045229": { - "Type": "AWS::CloudWatch::CompositeAlarm", - "Properties": { - "AlarmName": "awsappconfigenvironmentMyCompositeAlarm730A7A48", - "AlarmRule": { - "Fn::Join": [ - "", - [ - "ALARM(\"", - { - "Fn::GetAtt": [ - "MyAlarm696658B6", - "Arn" - ] - }, - "\")" - ] - ] - } - } - }, "MyEnvironmentRole01C8C013F": { "Type": "AWS::IAM::Role", "Properties": { @@ -93,57 +72,6 @@ ] } }, - "MyEnvironmentRole51BFC2F05": { - "Type": "AWS::IAM::Role", - "Properties": { - "AssumeRolePolicyDocument": { - "Statement": [ - { - "Action": "sts:AssumeRole", - "Effect": "Allow", - "Principal": { - "Service": "appconfig.amazonaws.com" - } - } - ], - "Version": "2012-10-17" - }, - "Policies": [ - { - "PolicyDocument": { - "Statement": [ - { - "Action": "cloudwatch:DescribeAlarms", - "Effect": "Allow", - "Resource": { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":cloudwatch:", - { - "Ref": "AWS::Region" - }, - ":", - { - "Ref": "AWS::AccountId" - }, - ":alarm:*" - ] - ] - } - } - ], - "Version": "2012-10-17" - }, - "PolicyName": "AllowAppConfigMonitorAlarmPolicy" - } - ] - } - }, "MyEnvironment465E4DEA": { "Type": "AWS::AppConfig::Environment", "Properties": { @@ -179,20 +107,6 @@ "Arn" ] } - }, - { - "AlarmArn": { - "Fn::GetAtt": [ - "MyCompositeAlarm0F045229", - "Arn" - ] - }, - "AlarmRoleArn": { - "Fn::GetAtt": [ - "MyEnvironmentRole51BFC2F05", - "Arn" - ] - } } ], "Name": "awsappconfigenvironment-MyEnvironment-C8813182" diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/manifest.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/manifest.json index ad09565da8609..4c038cd5bcd81 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/manifest.json @@ -18,7 +18,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/4acf8ce55e047ee524070ef3dbc29548495dfbd975bb2ec9927da4e529199c8f.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/ea755ac1ccc8e2c8816cf7e0a2b3789e472a166174037cb50eb45ec4ed621ba4.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -52,54 +52,18 @@ "data": "MyRoleF48FFE04" } ], - "/aws-appconfig-environment/MyCompositeAlarm/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MyCompositeAlarm0F045229" - } - ], "/aws-appconfig-environment/MyEnvironment/Role0/Resource": [ { "type": "aws:cdk:logicalId", "data": "MyEnvironmentRole01C8C013F" } ], - "/aws-appconfig-environment/MyEnvironment/Role5/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MyEnvironmentRole51BFC2F05" - } - ], "/aws-appconfig-environment/MyEnvironment/Resource": [ { "type": "aws:cdk:logicalId", "data": "MyEnvironment465E4DEA" } ], - "/aws-appconfig-environment/MyDeploymentStrategy/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MyDeploymentStrategy60D31FB0" - } - ], - "/aws-appconfig-environment/MyHostedConfig/ConfigurationProfile": [ - { - "type": "aws:cdk:logicalId", - "data": "MyHostedConfigConfigurationProfile2E1A2BBC" - } - ], - "/aws-appconfig-environment/MyHostedConfig/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MyHostedConfig51D3877D" - } - ], - "/aws-appconfig-environment/MyHostedConfig/Deployment99294": [ - { - "type": "aws:cdk:logicalId", - "data": "MyHostedConfigDeployment992941D06B01E" - } - ], "/aws-appconfig-environment/BootstrapVersion": [ { "type": "aws:cdk:logicalId", diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/tree.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/tree.json index 4051902e94c08..9b1d723134bbf 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/tree.json @@ -105,45 +105,6 @@ "version": "0.0.0" } }, - "MyCompositeAlarm": { - "id": "MyCompositeAlarm", - "path": "aws-appconfig-environment/MyCompositeAlarm", - "children": { - "Resource": { - "id": "Resource", - "path": "aws-appconfig-environment/MyCompositeAlarm/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::CloudWatch::CompositeAlarm", - "aws:cdk:cloudformation:props": { - "alarmName": "awsappconfigenvironmentMyCompositeAlarm730A7A48", - "alarmRule": { - "Fn::Join": [ - "", - [ - "ALARM(\"", - { - "Fn::GetAtt": [ - "MyAlarm696658B6", - "Arn" - ] - }, - "\")" - ] - ] - } - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_cloudwatch.CfnCompositeAlarm", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_cloudwatch.CompositeAlarm", - "version": "0.0.0" - } - }, "MyEnvironment": { "id": "MyEnvironment", "path": "aws-appconfig-environment/MyEnvironment", @@ -211,83 +172,6 @@ "version": "0.0.0" } }, - "Role5": { - "id": "Role5", - "path": "aws-appconfig-environment/MyEnvironment/Role5", - "children": { - "ImportRole5": { - "id": "ImportRole5", - "path": "aws-appconfig-environment/MyEnvironment/Role5/ImportRole5", - "constructInfo": { - "fqn": "aws-cdk-lib.Resource", - "version": "0.0.0" - } - }, - "Resource": { - "id": "Resource", - "path": "aws-appconfig-environment/MyEnvironment/Role5/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::IAM::Role", - "aws:cdk:cloudformation:props": { - "assumeRolePolicyDocument": { - "Statement": [ - { - "Action": "sts:AssumeRole", - "Effect": "Allow", - "Principal": { - "Service": "appconfig.amazonaws.com" - } - } - ], - "Version": "2012-10-17" - }, - "policies": [ - { - "policyName": "AllowAppConfigMonitorAlarmPolicy", - "policyDocument": { - "Statement": [ - { - "Action": "cloudwatch:DescribeAlarms", - "Effect": "Allow", - "Resource": { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":cloudwatch:", - { - "Ref": "AWS::Region" - }, - ":", - { - "Ref": "AWS::AccountId" - }, - ":alarm:*" - ] - ] - } - } - ], - "Version": "2012-10-17" - } - } - ] - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_iam.CfnRole", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_iam.Role", - "version": "0.0.0" - } - }, "Resource": { "id": "Resource", "path": "aws-appconfig-environment/MyEnvironment/Resource", @@ -326,20 +210,6 @@ "Arn" ] } - }, - { - "alarmArn": { - "Fn::GetAtt": [ - "MyCompositeAlarm0F045229", - "Arn" - ] - }, - "alarmRoleArn": { - "Fn::GetAtt": [ - "MyEnvironmentRole51BFC2F05", - "Arn" - ] - } } ], "name": "awsappconfigenvironment-MyEnvironment-C8813182" @@ -356,112 +226,6 @@ "version": "0.0.0" } }, - "MyDeploymentStrategy": { - "id": "MyDeploymentStrategy", - "path": "aws-appconfig-environment/MyDeploymentStrategy", - "children": { - "Resource": { - "id": "Resource", - "path": "aws-appconfig-environment/MyDeploymentStrategy/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::AppConfig::DeploymentStrategy", - "aws:cdk:cloudformation:props": { - "deploymentDurationInMinutes": 1, - "finalBakeTimeInMinutes": 1, - "growthFactor": 50, - "growthType": "LINEAR", - "name": "awsappconfigenvironment-MyDeploymentStrategy-28486041", - "replicateTo": "NONE" - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_appconfig.CfnDeploymentStrategy", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-appconfig-alpha.DeploymentStrategy", - "version": "0.0.0" - } - }, - "MyHostedConfig": { - "id": "MyHostedConfig", - "path": "aws-appconfig-environment/MyHostedConfig", - "children": { - "ConfigurationProfile": { - "id": "ConfigurationProfile", - "path": "aws-appconfig-environment/MyHostedConfig/ConfigurationProfile", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::AppConfig::ConfigurationProfile", - "aws:cdk:cloudformation:props": { - "applicationId": { - "Ref": "MyApplicationForEnv1F597ED9" - }, - "locationUri": "hosted", - "name": "awsappconfigenvironment-MyHostedConfig-26BB3558" - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_appconfig.CfnConfigurationProfile", - "version": "0.0.0" - } - }, - "Resource": { - "id": "Resource", - "path": "aws-appconfig-environment/MyHostedConfig/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::AppConfig::HostedConfigurationVersion", - "aws:cdk:cloudformation:props": { - "applicationId": { - "Ref": "MyApplicationForEnv1F597ED9" - }, - "configurationProfileId": { - "Ref": "MyHostedConfigConfigurationProfile2E1A2BBC" - }, - "content": "config content", - "contentType": "text/plain" - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_appconfig.CfnHostedConfigurationVersion", - "version": "0.0.0" - } - }, - "Deployment99294": { - "id": "Deployment99294", - "path": "aws-appconfig-environment/MyHostedConfig/Deployment99294", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::AppConfig::Deployment", - "aws:cdk:cloudformation:props": { - "applicationId": { - "Ref": "MyApplicationForEnv1F597ED9" - }, - "configurationProfileId": { - "Ref": "MyHostedConfigConfigurationProfile2E1A2BBC" - }, - "configurationVersion": { - "Ref": "MyHostedConfig51D3877D" - }, - "deploymentStrategyId": { - "Ref": "MyDeploymentStrategy60D31FB0" - }, - "environmentId": { - "Ref": "MyEnvironment465E4DEA" - } - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_appconfig.CfnDeployment", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-appconfig-alpha.HostedConfiguration", - "version": "0.0.0" - } - }, "BootstrapVersion": { "id": "BootstrapVersion", "path": "aws-appconfig-environment/BootstrapVersion", From 7fd9ed1ae9e71a3e5b5b2d0bf995bfade79317b0 Mon Sep 17 00:00:00 2001 From: Jane Chen Date: Thu, 30 Nov 2023 11:15:05 -0500 Subject: [PATCH 6/6] Add integ test snapshot --- ...efaultTestDeployAssert75BD28E7.assets.json | 2 +- .../aws-appconfig-environment.assets.json | 6 +- .../aws-appconfig-environment.template.json | 86 +++++++++++ .../integ.environment.js.snapshot/cdk.out | 2 +- .../integ.environment.js.snapshot/integ.json | 2 +- .../manifest.json | 16 ++- .../integ.environment.js.snapshot/tree.json | 134 +++++++++++++++++- 7 files changed, 238 insertions(+), 10 deletions(-) diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/appconfigenvironmentDefaultTestDeployAssert75BD28E7.assets.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/appconfigenvironmentDefaultTestDeployAssert75BD28E7.assets.json index 49f0e48e091a4..87b95745076b2 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/appconfigenvironmentDefaultTestDeployAssert75BD28E7.assets.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/appconfigenvironmentDefaultTestDeployAssert75BD28E7.assets.json @@ -1,5 +1,5 @@ { - "version": "34.0.0", + "version": "35.0.0", "files": { "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { "source": { diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.assets.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.assets.json index 89f92e7bd5dc4..fa54d57aa0d8a 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.assets.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.assets.json @@ -1,7 +1,7 @@ { - "version": "34.0.0", + "version": "35.0.0", "files": { - "ea755ac1ccc8e2c8816cf7e0a2b3789e472a166174037cb50eb45ec4ed621ba4": { + "6452c0ef7699cda5c609159e92012f180afda9cac21a0cba23acff97b8734de7": { "source": { "path": "aws-appconfig-environment.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "ea755ac1ccc8e2c8816cf7e0a2b3789e472a166174037cb50eb45ec4ed621ba4.json", + "objectKey": "6452c0ef7699cda5c609159e92012f180afda9cac21a0cba23acff97b8734de7.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.template.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.template.json index c3951447345b9..bb9c67d5ebfcb 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.template.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.template.json @@ -35,6 +35,27 @@ } } }, + "MyCompositeAlarm0F045229": { + "Type": "AWS::CloudWatch::CompositeAlarm", + "Properties": { + "AlarmName": "awsappconfigenvironmentMyCompositeAlarm730A7A48", + "AlarmRule": { + "Fn::Join": [ + "", + [ + "ALARM(\"", + { + "Fn::GetAtt": [ + "MyAlarm696658B6", + "Arn" + ] + }, + "\")" + ] + ] + } + } + }, "MyEnvironmentRole01C8C013F": { "Type": "AWS::IAM::Role", "Properties": { @@ -72,6 +93,57 @@ ] } }, + "MyEnvironmentRoleCompositeAlarm8C2A0542": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "appconfig.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "Policies": [ + { + "PolicyDocument": { + "Statement": [ + { + "Action": "cloudwatch:DescribeAlarms", + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":cloudwatch:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":alarm:*" + ] + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "AllowAppConfigMonitorAlarmPolicy" + } + ] + } + }, "MyEnvironment465E4DEA": { "Type": "AWS::AppConfig::Environment", "Properties": { @@ -107,6 +179,20 @@ "Arn" ] } + }, + { + "AlarmArn": { + "Fn::GetAtt": [ + "MyCompositeAlarm0F045229", + "Arn" + ] + }, + "AlarmRoleArn": { + "Fn::GetAtt": [ + "MyEnvironmentRoleCompositeAlarm8C2A0542", + "Arn" + ] + } } ], "Name": "awsappconfigenvironment-MyEnvironment-C8813182" diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/cdk.out b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/cdk.out index 2313ab5436501..c5cb2e5de6344 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/cdk.out +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"34.0.0"} \ No newline at end of file +{"version":"35.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/integ.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/integ.json index a9ffb18c9ba71..8c6291ddb72a5 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/integ.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "34.0.0", + "version": "35.0.0", "testCases": { "appconfig-environment/DefaultTest": { "stacks": [ diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/manifest.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/manifest.json index 4c038cd5bcd81..cb504329bc8a0 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "34.0.0", + "version": "35.0.0", "artifacts": { "aws-appconfig-environment.assets": { "type": "cdk:asset-manifest", @@ -18,7 +18,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/ea755ac1ccc8e2c8816cf7e0a2b3789e472a166174037cb50eb45ec4ed621ba4.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/6452c0ef7699cda5c609159e92012f180afda9cac21a0cba23acff97b8734de7.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -52,12 +52,24 @@ "data": "MyRoleF48FFE04" } ], + "/aws-appconfig-environment/MyCompositeAlarm/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyCompositeAlarm0F045229" + } + ], "/aws-appconfig-environment/MyEnvironment/Role0/Resource": [ { "type": "aws:cdk:logicalId", "data": "MyEnvironmentRole01C8C013F" } ], + "/aws-appconfig-environment/MyEnvironment/RoleCompositeAlarm/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyEnvironmentRoleCompositeAlarm8C2A0542" + } + ], "/aws-appconfig-environment/MyEnvironment/Resource": [ { "type": "aws:cdk:logicalId", diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/tree.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/tree.json index 9b1d723134bbf..744719477b065 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/tree.json @@ -105,6 +105,45 @@ "version": "0.0.0" } }, + "MyCompositeAlarm": { + "id": "MyCompositeAlarm", + "path": "aws-appconfig-environment/MyCompositeAlarm", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-appconfig-environment/MyCompositeAlarm/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::CloudWatch::CompositeAlarm", + "aws:cdk:cloudformation:props": { + "alarmName": "awsappconfigenvironmentMyCompositeAlarm730A7A48", + "alarmRule": { + "Fn::Join": [ + "", + [ + "ALARM(\"", + { + "Fn::GetAtt": [ + "MyAlarm696658B6", + "Arn" + ] + }, + "\")" + ] + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_cloudwatch.CfnCompositeAlarm", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_cloudwatch.CompositeAlarm", + "version": "0.0.0" + } + }, "MyEnvironment": { "id": "MyEnvironment", "path": "aws-appconfig-environment/MyEnvironment", @@ -172,6 +211,83 @@ "version": "0.0.0" } }, + "RoleCompositeAlarm": { + "id": "RoleCompositeAlarm", + "path": "aws-appconfig-environment/MyEnvironment/RoleCompositeAlarm", + "children": { + "ImportRoleCompositeAlarm": { + "id": "ImportRoleCompositeAlarm", + "path": "aws-appconfig-environment/MyEnvironment/RoleCompositeAlarm/ImportRoleCompositeAlarm", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-appconfig-environment/MyEnvironment/RoleCompositeAlarm/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "appconfig.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "policies": [ + { + "policyName": "AllowAppConfigMonitorAlarmPolicy", + "policyDocument": { + "Statement": [ + { + "Action": "cloudwatch:DescribeAlarms", + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":cloudwatch:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":alarm:*" + ] + ] + } + } + ], + "Version": "2012-10-17" + } + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, "Resource": { "id": "Resource", "path": "aws-appconfig-environment/MyEnvironment/Resource", @@ -210,6 +326,20 @@ "Arn" ] } + }, + { + "alarmArn": { + "Fn::GetAtt": [ + "MyCompositeAlarm0F045229", + "Arn" + ] + }, + "alarmRoleArn": { + "Fn::GetAtt": [ + "MyEnvironmentRoleCompositeAlarm8C2A0542", + "Arn" + ] + } } ], "name": "awsappconfigenvironment-MyEnvironment-C8813182" @@ -261,7 +391,7 @@ "path": "appconfig-environment/DefaultTest/Default", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.70" + "version": "10.3.0" } }, "DeployAssert": { @@ -307,7 +437,7 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.70" + "version": "10.3.0" } } },