From 694dc73d7490a50ff9c5113aea4454f6ec8bf72a Mon Sep 17 00:00:00 2001 From: Jane Chen Date: Wed, 7 Feb 2024 12:11:44 -0500 Subject: [PATCH 1/4] chore(appconfig): refactor README and integ tests --- .../@aws-cdk/aws-appconfig-alpha/README.md | 206 +++++++++++------- ...efaultTestDeployAssertD6537C40.assets.json | 2 +- .../aws-appconfig-application.assets.json | 6 +- .../aws-appconfig-application.template.json | 2 +- .../integ.application.js.snapshot/cdk.out | 2 +- .../integ.application.js.snapshot/integ.json | 2 +- .../manifest.json | 6 +- .../integ.application.js.snapshot/tree.json | 8 +- .../test/integ.application.ts | 5 + .../test/integ.configuration.ts | 4 + .../test/integ.deployment-strategy.ts | 4 + .../test/integ.environment.ts | 4 + .../test/integ.extension.ts | 4 + 13 files changed, 160 insertions(+), 95 deletions(-) diff --git a/packages/@aws-cdk/aws-appconfig-alpha/README.md b/packages/@aws-cdk/aws-appconfig-alpha/README.md index f7a658fdc5ab8..80b19ee6e9644 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/README.md +++ b/packages/@aws-cdk/aws-appconfig-alpha/README.md @@ -18,16 +18,52 @@ This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project. -Use AWS AppConfig, a capability of AWS Systems Manager, to create, manage, and quickly deploy application configurations. A configuration is a collection of settings that influence the behavior of your application. You can use AWS AppConfig with applications hosted on Amazon Elastic Compute Cloud (Amazon EC2) instances, AWS Lambda, containers, mobile applications, or IoT devices. To view examples of the types of configurations you can manage by using AWS AppConfig, see [Example configurations](https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-creating-configuration-and-profile.html#appconfig-creating-configuration-and-profile-examples). +For a high level overview of what AWS AppConfig is and how it works, please take a look here: +[What is AWS AppConfig?](https://docs.aws.amazon.com/appconfig/latest/userguide/what-is-appconfig.html) + + +## Basic Hosted Configuration Use Case + +> The main way most AWS AppConfig users utilize the service is through hosted configuration, which involves storing +configuration data directly within AWS AppConfig. + +An example use case: + +```ts +const app = new appconfig.Application(this, 'MyApp'); +const env = new appconfig.Environment(this, 'MyEnv', { + application: app, +}); + +new appconfig.HostedConfiguration(this, 'MyHostedConfig', { + application: app, + deployTo: [env], + content: appconfig.ConfigurationContent.fromInlineText('This is my configuration content.'), +}); + +``` + +This will create the application and environment for your configuration and then deploy your configuration to the +specified environment. + +For more information about what these resources are: [Creating feature flags and free form configuration data in AWS AppConfig](https://docs.aws.amazon.com/appconfig/latest/userguide/creating-feature-flags-and-configuration-data.html). + +For more information about deploying configuration: [Deploying feature flags and configuration data in AWS AppConfig](https://docs.aws.amazon.com/appconfig/latest/userguide/deploying-feature-flags.html) + +____ + +For an in-depth walkthrough of specific resources and how to use them, please take a look at the following sections. ## Application -In AWS AppConfig, an application is simply an organizational construct like a folder. This organizational construct has a -relationship with some unit of executable code. For example, you could create an application called MyMobileApp to organize and -manage configuration data for a mobile application installed by your users. Configurations and environments are associated with -the application. +[AWS AppConfig Application Documentation](https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-creating-namespace.html) -The name and description of an application are optional. +In AWS AppConfig, an application is simply an organizational +construct like a folder. Configurations and environments are +associated with the application. + +When creating an application through CDK, the name and +description of an application are optional. Create a simple application: @@ -35,20 +71,35 @@ Create a simple application: new appconfig.Application(this, 'MyApplication'); ``` -Create an application with a name and description: +## Environment + +[AWS AppConfig Environment Documentation](https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-creating-environment.html) + +Basic environment with monitors: ```ts -new appconfig.Application(this, 'MyApplication', { - applicationName: 'App1', - description: 'This is my application created through CDK.', +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), + ], }); ``` +Environment monitors also support L1 CfnEnvironment.MonitorsProperty constructs. However, this is not the recommended approach +for CloudWatch alarms because a role will not be auto-generated if not provided. + ## Deployment Strategy -A deployment strategy defines how a configuration will roll out. The roll out is defined by four parameters: deployment type, -step percentage, deployment time, and bake time. -See: https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-creating-deployment-strategy.html +[AWS AppConfig Deployment Strategy Documentation](https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-creating-deployment-strategy.html) + +A deployment strategy defines how a configuration will roll out. The roll out is defined by four parameters: deployment type, +growth factor, deployment duration, and final bake time. Deployment strategy with predefined values: @@ -70,13 +121,13 @@ new appconfig.DeploymentStrategy(this, 'MyDeploymentStrategy', { }); ``` -Importing a deployment strategy by ID: +Referencing a deployment strategy by ID: ```ts appconfig.DeploymentStrategy.fromDeploymentStrategyId(this, 'MyImportedDeploymentStrategy', appconfig.DeploymentStrategyId.fromString('abc123')); ``` -Importing an AWS AppConfig predefined deployment strategy by ID: +Referencing an AWS AppConfig predefined deployment strategy by ID: ```ts appconfig.DeploymentStrategy.fromDeploymentStrategyId( @@ -98,6 +149,22 @@ A hosted configuration represents configuration stored in the AWS AppConfig host takes in the configuration content and associated AWS AppConfig application. On construction of a hosted configuration, the configuration is deployed. +You can define hosted configuration content using any of the following ConfigurationContent methods: + +* `fromFile` - Defines the hosted configuration content from a file (you can specify a relative path). The content type will +be determined by the file extension unless specified. + +```ts +declare const application: appconfig.Application; + +new appconfig.HostedConfiguration(this, 'MyHostedConfiguration', { + application, + content: appconfig.ConfigurationContent.fromFile('config.json'), +}); +``` + +* `fromInlineText` - Defines the hosted configuration from inline text. The content type will be set as `text/plain`. + ```ts declare const application: appconfig.Application; @@ -107,18 +174,43 @@ new appconfig.HostedConfiguration(this, 'MyHostedConfiguration', { }); ``` -You can define hosted configuration content using any of the following ConfigurationContent methods: +* `fromInlineJson` - Defines the hosted configuration from inline JSON. The content type will be set as `application/json` unless specified. + +```ts +declare const application: appconfig.Application; + +new appconfig.HostedConfiguration(this, 'MyHostedConfiguration', { + application, + content: appconfig.ConfigurationContent.fromInlineJson('{}'), +}); +``` + +* `fromInlineYaml` - Defines the hosted configuration from inline YAML. The content type will be set as `application/x-yaml`. + +```ts +declare const application: appconfig.Application; -* `fromFile` - Defines the hosted configuration content from a file (you can specify a relative path). -* `fromInlineText` - Defines the hosted configuration from inline text. -* `fromInlineJson` - Defines the hosted configuration from inline JSON. -* `fromInlineYaml` - Defines the hosted configuration from inline YAML. -* `fromInline` - Defines the hosted configuration from user-specified content types. +new appconfig.HostedConfiguration(this, 'MyHostedConfiguration', { + application, + content: appconfig.ConfigurationContent.fromInlineYaml('MyConfig: This is my content.'), +}); +``` + +* `fromInline` - Defines the hosted configuration from user-specified content types. The content type will be set as `application/octet-stream` unless specified. + +```ts +declare const application: appconfig.Application; + +new appconfig.HostedConfiguration(this, 'MyHostedConfiguration', { + application, + content: appconfig.ConfigurationContent.fromInline('This is my configuration content.'), +}); +``` AWS AppConfig supports the following types of configuration profiles. -* **Feature flag**: Use a feature flag configuration to turn on new features that require a timely deployment, such as a product launch or announcement. -* **Freeform**: Use a freeform configuration to carefully introduce changes to your application. +* **[Feature flag](https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-creating-configuration-and-profile-feature-flags.html)**: Use a feature flag configuration to turn on new features that require a timely deployment, such as a product launch or announcement. +* **[Freeform](https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-free-form-configurations-creating.html)**: Use a freeform configuration to carefully introduce changes to your application. A hosted configuration with type: @@ -192,24 +284,18 @@ new appconfig.HostedConfiguration(this, 'MyHostedConfiguration', { }); ``` -To deploy a configuration to an environment after initialization use the `deploy` method: - -```ts -declare const application: appconfig.Application; -declare const env: appconfig.Environment; - -const config = new appconfig.HostedConfiguration(this, 'MyHostedConfiguration', { - application, - content: appconfig.ConfigurationContent.fromInlineText('This is my configuration content.'), -}); +### SourcedConfiguration -config.deploy(env); -``` +A sourced configuration represents configuration stored in any of the following: -### SourcedConfiguration +* Amazon S3 bucket +* AWS Secrets Manager secret +* Systems Manager +(SSM) Parameter Store parameter +* SSM document +* AWS CodePipeline. -A sourced configuration represents configuration stored in an Amazon S3 bucket, AWS Secrets Manager secret, Systems Manager -(SSM) Parameter Store parameter, SSM document, or AWS CodePipeline. A sourced configuration takes in the location source +A sourced configuration takes in the location source construct and optionally a version number to deploy. On construction of a sourced configuration, the configuration is deployed only if a version number is specified. @@ -356,50 +442,6 @@ new appconfig.SourcedConfiguration(this, 'MySourcedConfiguration', { }); ``` -The `deployTo` parameter is used to specify which environments to deploy the configuration to. If this parameter is not -specified, there will not be a deployment. - -A sourced configuration with `deployTo`: - -```ts -declare const application: appconfig.Application; -declare const bucket: s3.Bucket; -declare const env: appconfig.Environment; - -new appconfig.SourcedConfiguration(this, 'MySourcedConfiguration', { - application, - location: appconfig.ConfigurationSource.fromBucket(bucket, 'path/to/file.json'), - deployTo: [env], -}); -``` - -## Environment - -For each AWS AppConfig application, you define one or more environments. An environment is a logical deployment group of AWS -AppConfig targets, such as applications in a Beta or Production environment. You can also define environments for application -subcomponents such as the Web, Mobile, and Back-end components for your application. You can configure Amazon CloudWatch alarms -for each environment. The system monitors alarms during a configuration deployment. If an alarm is triggered, the system rolls -back the configuration. - -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), - ], -}); -``` - -Environment monitors also support L1 CfnEnvironment.MonitorsProperty constructs. However, this is not the recommended approach -for CloudWatch alarms because a role will not be auto-generated if not provided. - ## Extension An extension augments your ability to inject logic or behavior at different points during the AWS AppConfig workflow of diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/appconfigapplicationDefaultTestDeployAssertD6537C40.assets.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/appconfigapplicationDefaultTestDeployAssertD6537C40.assets.json index b6f615178fa21..2de973e7d532a 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/appconfigapplicationDefaultTestDeployAssertD6537C40.assets.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/appconfigapplicationDefaultTestDeployAssertD6537C40.assets.json @@ -1,5 +1,5 @@ { - "version": "32.0.0", + "version": "36.0.0", "files": { "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { "source": { diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/aws-appconfig-application.assets.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/aws-appconfig-application.assets.json index 264d0b0f3253f..589232ce06967 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/aws-appconfig-application.assets.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/aws-appconfig-application.assets.json @@ -1,7 +1,7 @@ { - "version": "32.0.0", + "version": "36.0.0", "files": { - "1bbcd83a6b27b680c911215e6afe359b98571c3d9d715d5ebf40ae0522a31c33": { + "e9c7efc5ccbc9637d562dcbcefc3713d4e81f48aff6a62cef50c80d78500d2ed": { "source": { "path": "aws-appconfig-application.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "1bbcd83a6b27b680c911215e6afe359b98571c3d9d715d5ebf40ae0522a31c33.json", + "objectKey": "e9c7efc5ccbc9637d562dcbcefc3713d4e81f48aff6a62cef50c80d78500d2ed.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.application.js.snapshot/aws-appconfig-application.template.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/aws-appconfig-application.template.json index 6cbd018c1b9d1..12c5a040e6bef 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/aws-appconfig-application.template.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/aws-appconfig-application.template.json @@ -4,7 +4,7 @@ "Type": "AWS::AppConfig::Application", "Properties": { "Description": "This is my application for testing", - "Name": "awsappconfigapplication-MyAppConfig-5BFACBE9" + "Name": "MySampleApplication" } }, "MyTaskDefTaskRole727F9D3B": { diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/cdk.out b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/cdk.out index f0b901e7c06e5..1f0068d32659a 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/cdk.out +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"32.0.0"} \ No newline at end of file +{"version":"36.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/integ.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/integ.json index 02a72ca75410e..f4b1471d0b104 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/integ.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "32.0.0", + "version": "36.0.0", "testCases": { "appconfig-application/DefaultTest": { "stacks": [ diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/manifest.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/manifest.json index bc03046086754..a02b53e19b078 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "32.0.0", + "version": "36.0.0", "artifacts": { "aws-appconfig-application.assets": { "type": "cdk:asset-manifest", @@ -14,10 +14,11 @@ "environment": "aws://unknown-account/unknown-region", "properties": { "templateFile": "aws-appconfig-application.template.json", + "terminationProtection": false, "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}/1bbcd83a6b27b680c911215e6afe359b98571c3d9d715d5ebf40ae0522a31c33.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/e9c7efc5ccbc9637d562dcbcefc3713d4e81f48aff6a62cef50c80d78500d2ed.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -79,6 +80,7 @@ "environment": "aws://unknown-account/unknown-region", "properties": { "templateFile": "appconfigapplicationDefaultTestDeployAssertD6537C40.template.json", + "terminationProtection": false, "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}", diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/tree.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/tree.json index 9d9934f4ae1b5..9a82fceaea7ac 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.js.snapshot/tree.json @@ -19,7 +19,7 @@ "aws:cdk:cloudformation:type": "AWS::AppConfig::Application", "aws:cdk:cloudformation:props": { "description": "This is my application for testing", - "name": "awsappconfigapplication-MyAppConfig-5BFACBE9" + "name": "MySampleApplication" } }, "constructInfo": { @@ -29,7 +29,7 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.Resource", + "fqn": "@aws-cdk/aws-appconfig-alpha.Application", "version": "0.0.0" } }, @@ -162,7 +162,7 @@ "path": "appconfig-application/DefaultTest/Default", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.69" + "version": "10.3.0" } }, "DeployAssert": { @@ -208,7 +208,7 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.69" + "version": "10.3.0" } } }, diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.ts b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.ts index 92f6830918ccd..572b854af1d92 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.application.ts @@ -9,11 +9,16 @@ const stack = new Stack(app, 'aws-appconfig-application'); new Application(stack, 'MyAppConfig', { description: 'This is my application for testing', + applicationName: 'MySampleApplication', }); const taskDef = new FargateTaskDefinition(stack, 'MyTaskDef'); Application.addAgentToEcs(taskDef); +/* resource deployment alone is sufficient because we already have the + corresponding resource handler tests to assert that resources can be + used after created */ + new IntegTest(app, 'appconfig-application', { testCases: [stack], }); \ No newline at end of file diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.ts b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.ts index 53b3cd161ac8d..d3a6c9d7f980e 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.ts @@ -216,6 +216,10 @@ new SourcedConfiguration(stack, 'MyConfigFromPipeline', { location: ConfigurationSource.fromPipeline(pipeline), }); +/* resource deployment alone is sufficient because we already have the + corresponding resource handler tests to assert that resources can be + used after created */ + new IntegTest(app, 'appconfig-configuration', { testCases: [stack], cdkCommandOptions: { diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.deployment-strategy.ts b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.deployment-strategy.ts index 0aadaeeab707e..b6c93c7da8b7c 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.deployment-strategy.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.deployment-strategy.ts @@ -14,6 +14,10 @@ new DeploymentStrategy(stack, 'MyDeploymentStrategy', { }), }); +/* resource deployment alone is sufficient because we already have the + corresponding resource handler tests to assert that resources can be + used after created */ + new IntegTest(app, 'appconfig-deployment-strategy', { testCases: [stack], }); 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 6681c66597bd4..31e2af822572e 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.ts @@ -41,6 +41,10 @@ new Environment(stack, 'MyEnvironment', { ], }); +/* resource deployment alone is sufficient because we already have the + corresponding resource handler tests to assert that resources can be + used after created */ + new IntegTest(app, 'appconfig-environment', { testCases: [stack], }); diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.ts b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.ts index 0fdfd86d92e80..3fd34dc2b7626 100755 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.ts @@ -109,6 +109,10 @@ const hostedConfig = new HostedConfiguration(stack, 'HostedConfiguration', { }); hostedConfig.node.addDependency(lambdaExtension, topicExtension, busExtension, queueExtension); +/* resource deployment alone is sufficient because we already have the + corresponding resource handler tests to assert that resources can be + used after created */ + new IntegTest(app, 'appconfig-extension', { testCases: [stack], cdkCommandOptions: { From 46c9fba9812d2d2155f99b437916d550f519ecfb Mon Sep 17 00:00:00 2001 From: Jane Chen Date: Wed, 7 Feb 2024 12:11:44 -0500 Subject: [PATCH 2/4] chore(appconfig): refactor README and integ tests --- packages/@aws-cdk/aws-appconfig-alpha/README.md | 9 ++++----- packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/@aws-cdk/aws-appconfig-alpha/README.md b/packages/@aws-cdk/aws-appconfig-alpha/README.md index 80b19ee6e9644..57605ee86f350 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/README.md +++ b/packages/@aws-cdk/aws-appconfig-alpha/README.md @@ -25,7 +25,7 @@ For a high level overview of what AWS AppConfig is and how it works, please take ## Basic Hosted Configuration Use Case > The main way most AWS AppConfig users utilize the service is through hosted configuration, which involves storing -configuration data directly within AWS AppConfig. +> configuration data directly within AWS AppConfig. An example use case: @@ -40,7 +40,6 @@ new appconfig.HostedConfiguration(this, 'MyHostedConfig', { deployTo: [env], content: appconfig.ConfigurationContent.fromInlineText('This is my configuration content.'), }); - ``` This will create the application and environment for your configuration and then deploy your configuration to the @@ -91,8 +90,8 @@ new appconfig.Environment(this, 'MyEnvironment', { }); ``` -Environment monitors also support L1 CfnEnvironment.MonitorsProperty constructs. However, this is not the recommended approach -for CloudWatch alarms because a role will not be auto-generated if not provided. +Environment monitors also support L1 `CfnEnvironment.MonitorsProperty` constructs through the `fromCfnMonitorsProperty` method. +However, this is not the recommended approach for CloudWatch alarms because a role will not be auto-generated if not provided. ## Deployment Strategy @@ -291,7 +290,7 @@ A sourced configuration represents configuration stored in any of the following: * Amazon S3 bucket * AWS Secrets Manager secret * Systems Manager -(SSM) Parameter Store parameter +* (SSM) Parameter Store parameter * SSM document * AWS CodePipeline. diff --git a/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts b/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts index 767373f92da81..ff8b2ca233e6f 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts @@ -348,8 +348,9 @@ export abstract class Monitor { * @param monitorsProperty The monitors property. */ public static fromCfnMonitorsProperty(monitorsProperty: CfnEnvironment.MonitorsProperty): Monitor { + if (monitorsProperty.alarmArn === undefined) { throw new Error('need this prop'); } return { - alarmArn: monitorsProperty.alarmArn!, + alarmArn: monitorsProperty.alarmArn, alarmRoleArn: monitorsProperty.alarmRoleArn, monitorType: MonitorType.CFN_MONITORS_PROPERTY, }; From b2ff31ad002c2ee373e233a6837060ef378d8c1d Mon Sep 17 00:00:00 2001 From: Jane Chen Date: Fri, 9 Feb 2024 09:34:39 -0500 Subject: [PATCH 3/4] better error message --- packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts b/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts index ff8b2ca233e6f..c04f901a5bb9e 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts @@ -348,7 +348,7 @@ export abstract class Monitor { * @param monitorsProperty The monitors property. */ public static fromCfnMonitorsProperty(monitorsProperty: CfnEnvironment.MonitorsProperty): Monitor { - if (monitorsProperty.alarmArn === undefined) { throw new Error('need this prop'); } + if (monitorsProperty.alarmArn === undefined) { throw new Error('need to specify an alarmArn property'); } return { alarmArn: monitorsProperty.alarmArn, alarmRoleArn: monitorsProperty.alarmRoleArn, From 045b616e722ac2ae05721f24dd9df764a73ed896 Mon Sep 17 00:00:00 2001 From: Kaizen Conroy <36202692+kaizencc@users.noreply.github.com> Date: Fri, 9 Feb 2024 12:55:54 -0500 Subject: [PATCH 4/4] Update packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts --- packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts b/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts index c04f901a5bb9e..d85ecab12e231 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts @@ -348,7 +348,9 @@ export abstract class Monitor { * @param monitorsProperty The monitors property. */ public static fromCfnMonitorsProperty(monitorsProperty: CfnEnvironment.MonitorsProperty): Monitor { - if (monitorsProperty.alarmArn === undefined) { throw new Error('need to specify an alarmArn property'); } + if (monitorsProperty.alarmArn === undefined) { + throw new Error('You must specify an alarmArn property to use "fromCfnMonitorsProperty".'); + } return { alarmArn: monitorsProperty.alarmArn, alarmRoleArn: monitorsProperty.alarmRoleArn,