From 8a0f0a6c4a1042adf65463a303ec2854b701e143 Mon Sep 17 00:00:00 2001 From: Jane Chen Date: Tue, 15 Aug 2023 18:06:40 -0400 Subject: [PATCH 1/3] refactor(appconfig): refactoring deployTo and contentType properties --- package.json | 2 + .../@aws-cdk/aws-appconfig-alpha/README.md | 14 +- .../aws-appconfig-alpha/lib/configuration.ts | 67 ++++--- .../@aws-cdk/aws-appconfig-alpha/package.json | 15 +- .../test/configuration.test.ts | 178 ++++++++++-------- .../test/extension.test.ts | 2 +- .../aws-appconfig-configuration.assets.json | 4 +- .../aws-appconfig-configuration.template.json | 4 +- .../manifest.json | 2 +- .../integ.configuration.js.snapshot/tree.json | 62 +++--- .../test/integ.configuration.ts | 4 +- .../test/integ.extension.ts | 2 +- 12 files changed, 200 insertions(+), 156 deletions(-) diff --git a/package.json b/package.json index 6313934749522..39259110fa0f9 100644 --- a/package.json +++ b/package.json @@ -96,6 +96,8 @@ "@aws-cdk/assertions-alpha/fs-extra/**", "@aws-cdk/assertions/fs-extra", "@aws-cdk/assertions/fs-extra/**", + "@aws-cdk/aws-appconfig-alpha/mime-types", + "@aws-cdk/aws-appconfig-alpha/mime-types/**", "@aws-cdk/aws-codebuild/yaml", "@aws-cdk/aws-codebuild/yaml/**", "@aws-cdk/aws-codepipeline-actions/case", diff --git a/packages/@aws-cdk/aws-appconfig-alpha/README.md b/packages/@aws-cdk/aws-appconfig-alpha/README.md index c20878cbbad24..2f29be7bba89e 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/README.md +++ b/packages/@aws-cdk/aws-appconfig-alpha/README.md @@ -79,7 +79,7 @@ declare const application: appconfig.Application; new appconfig.HostedConfiguration(this, 'MyHostedConfiguration', { application, - content: appconfig.ConfigurationContent.fromInline('This is my configuration content.'), + content: appconfig.ConfigurationContent.fromInlineText('This is my configuration content.'), }); ``` @@ -95,7 +95,7 @@ declare const application: appconfig.Application; new appconfig.HostedConfiguration(this, 'MyHostedConfiguration', { application, - content: appconfig.ConfigurationContent.fromInline('This is my configuration content.'), + content: appconfig.ConfigurationContent.fromInlineText('This is my configuration content.'), type: appconfig.ConfigurationType.FEATURE_FLAGS, }); ``` @@ -111,7 +111,7 @@ declare const fn: lambda.Function; new appconfig.HostedConfiguration(this, 'MyHostedConfiguration', { application, - content: appconfig.ConfigurationContent.fromInline('This is my configuration content.'), + content: appconfig.ConfigurationContent.fromInlineText('This is my configuration content.'), validators: [ appconfig.JsonSchemaValidator.fromFile('schema.json'), appconfig.LambdaValidator.fromFunction(fn), @@ -128,7 +128,7 @@ declare const application: appconfig.Application; new appconfig.HostedConfiguration(this, 'MyHostedConfiguration', { application, - content: appconfig.ConfigurationContent.fromInline('This is my configuration content.'), + content: appconfig.ConfigurationContent.fromInlineText('This is my configuration content.'), deploymentStrategy: new appconfig.DeploymentStrategy(this, 'MyDeploymentStrategy', { rolloutStrategy: appconfig.RolloutStrategy.linear({ growthFactor: 15, @@ -139,7 +139,7 @@ new appconfig.HostedConfiguration(this, 'MyHostedConfiguration', { }); ``` -The `deployTo` parameter is used to specify which environments to deploy the configuration to. If this parameter is not specified, there will only be a deployment if there is one environment associated to the AWS AppConfig application. +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 hosted configuration with `deployTo`: @@ -149,7 +149,7 @@ declare const env: appconfig.Environment; new appconfig.HostedConfiguration(this, 'MyHostedConfiguration', { application, - content: appconfig.ConfigurationContent.fromInline('This is my configuration content.'), + content: appconfig.ConfigurationContent.fromInlineText('This is my configuration content.'), deployTo: [env], }); ``` @@ -301,7 +301,7 @@ 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 only be a deployment if there is one environment associated to the AWS AppConfig application. +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`: diff --git a/packages/@aws-cdk/aws-appconfig-alpha/lib/configuration.ts b/packages/@aws-cdk/aws-appconfig-alpha/lib/configuration.ts index 0681f73487e08..51f36b406dd9c 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/lib/configuration.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/lib/configuration.ts @@ -1,4 +1,5 @@ import * as fs from 'fs'; +import * as mimeTypes from 'mime-types'; import { PhysicalName, Stack, ArnFormat, Names, RemovalPolicy } from 'aws-cdk-lib'; import { CfnConfigurationProfile, CfnDeployment, CfnHostedConfigurationVersion } from 'aws-cdk-lib/aws-appconfig'; import * as cp from 'aws-cdk-lib/aws-codepipeline'; @@ -55,9 +56,8 @@ export interface ConfigurationOptions { /** * The list of environments to deploy the configuration to. * - * If this parameter is not specified and there is only one environment - * associated to the application, then we will deploy to that one. Otherwise, - * there will be no deployment. + * If this parameter is not specified, then there will be no + * deployment. * * @default - None. */ @@ -305,13 +305,7 @@ abstract class ConfigurationBase extends Construct implements IConfiguration, IE } protected deployConfigToEnvironments() { - if (this.application.environments.length == 0) { - this.application.addEnvironment('Environment', { - description: this.description, - }); - } - - if ((!this.deployTo && this.application.environments.length > 1) || !this.versionNumber) { + if (!this.deployTo || !this.versionNumber) { return; } @@ -320,9 +314,6 @@ abstract class ConfigurationBase extends Construct implements IConfiguration, IE return; } const logicalId = `Deployment${this.getDeploymentHash(environment)}`; - if (this.node.tryFindChild(logicalId)) { - return; - } new CfnDeployment(this, logicalId, { applicationId: this.application.applicationId, configurationProfileId: this.configurationProfileId, @@ -342,11 +333,6 @@ export interface HostedConfigurationOptions extends ConfigurationOptions { */ readonly content: ConfigurationContent; - /** - * The content type of the hosted configuration. - */ - readonly contentType?: string; - /** * The latest version number of the hosted configuration. */ @@ -364,11 +350,6 @@ export interface HostedConfigurationProps extends ConfigurationProps { */ readonly content: ConfigurationContent; - /** - * The content type of the hosted configuration. - */ - readonly contentType?: string; - /** * The latest version number of the hosted configuration. */ @@ -444,7 +425,7 @@ export class HostedConfiguration extends ConfigurationBase { this.extensible = new ExtensibleBase(scope, this.configurationProfileArn, this.name); this.content = props.content.content; - this.contentType = props.contentType || 'application/json'; + this.contentType = props.content.contentType; this.latestVersionNumber = props.latestVersionNumber; this.versionLabel = props.versionLabel; this._cfnHostedConfigurationVersion = new CfnHostedConfigurationVersion(this, 'Resource', { @@ -792,10 +773,12 @@ export abstract class ConfigurationContent { * Defines the hosted configuration content from a file. * * @param path The path to the file that defines configuration content + * @param contentType The content type of the configuration */ - public static fromFile(path: string): ConfigurationContent { + public static fromFile(path: string, contentType?: string): ConfigurationContent { return { content: fs.readFileSync(path).toString(), + contentType: contentType || mimeTypes.lookup(path) || 'application/json', }; } @@ -803,10 +786,37 @@ export abstract class ConfigurationContent { * Defines the hosted configuration content from inline code. * * @param content The inline code that defines the configuration content + * @param contentType The content type of the configuration */ - public static fromInline(content: string): ConfigurationContent { + public static fromInline(content: string, contentType?: string): ConfigurationContent { return { content, + contentType: contentType || 'application/octet-stream', + }; + } + + /** + * Defines the hosted configuration content as JSON from inline code. + * + * @param content The inline code that defines the configuration content + * @param contentType The content type of the configuration + */ + public static fromInlineJson(content: string, contentType?: string): ConfigurationContent { + return { + content, + contentType: contentType || 'application/json', + }; + } + + /** + * Defines the hosted configuration content as text from inline code. + * + * @param content The inline code that defines the configuration content + */ + public static fromInlineText(content: string): ConfigurationContent { + return { + content, + contentType: 'text/plain', }; } @@ -814,6 +824,11 @@ export abstract class ConfigurationContent { * The configuration content. */ public abstract readonly content: string; + + /** + * The configuration content type. + */ + public abstract readonly contentType: string; } /** diff --git a/packages/@aws-cdk/aws-appconfig-alpha/package.json b/packages/@aws-cdk/aws-appconfig-alpha/package.json index 0c6b1342a7064..1b3a2512a7897 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/package.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/package.json @@ -76,18 +76,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "aws-cdk-lib": "0.0.0", "@aws-cdk/cdk-build-tools": "0.0.0", "@aws-cdk/integ-runner": "0.0.0", - "@aws-cdk/pkglint": "0.0.0", "@aws-cdk/integ-tests-alpha": "0.0.0", + "@aws-cdk/pkglint": "0.0.0", "@types/jest": "^29.5.3", + "@types/mime-types": "^2.1.1", + "aws-cdk-lib": "0.0.0", "constructs": "^10.0.0", - "jest": "^29.6.2" + "jest": "^29.6.1" }, "dependencies": { "aws-cdk-lib": "0.0.0", - "constructs": "^10.0.0" + "constructs": "^10.0.0", + "mime-types": "^2.1.35" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { @@ -115,5 +117,8 @@ "env": { "AWSLINT_BASE_CONSTRUCT": true } - } + }, + "bundleDependencies": [ + "mime-types" + ] } diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/configuration.test.ts b/packages/@aws-cdk/aws-appconfig-alpha/test/configuration.test.ts index 6022720431473..5e4479b61979b 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/configuration.test.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/configuration.test.ts @@ -25,7 +25,7 @@ describe('configuration', () => { const stack = new cdk.Stack(); const app = new Application(stack, 'MyAppConfig'); new HostedConfiguration(stack, 'MyHostedConfig', { - content: ConfigurationContent.fromInline('This is my content'), + content: ConfigurationContent.fromInlineText('This is my content'), application: app, deploymentStrategy: new DeploymentStrategy(stack, 'MyDeploymentStrategy', { rolloutStrategy: RolloutStrategy.linear({ @@ -35,12 +35,7 @@ describe('configuration', () => { }), }); - Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::Environment', { - Name: 'MyAppConfig-Environment-CF46384A', - ApplicationId: { - Ref: 'MyAppConfigB4B63E75', - }, - }); + Template.fromStack(stack).resourceCountIs('AWS::AppConfig::Environment', 0); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::ConfigurationProfile', { Name: 'MyHostedConfig', ApplicationId: { @@ -55,25 +50,9 @@ describe('configuration', () => { Ref: 'MyHostedConfigConfigurationProfile2E1A2BBC', }, Content: 'This is my content', - ContentType: 'application/json', - }); - Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::Deployment', { - ApplicationId: { - Ref: 'MyAppConfigB4B63E75', - }, - EnvironmentId: { - Ref: 'MyAppConfigEnvironment833A9182', - }, - ConfigurationVersion: { - Ref: 'MyHostedConfig51D3877D', - }, - ConfigurationProfileId: { - Ref: 'MyHostedConfigConfigurationProfile2E1A2BBC', - }, - DeploymentStrategyId: { - Ref: 'MyDeploymentStrategy60D31FB0', - }, + ContentType: 'text/plain', }); + Template.fromStack(stack).resourceCountIs('AWS::AppConfig::Deployment', 0); }); test('configuration with environments and no deployTo prop', () => { @@ -84,7 +63,7 @@ describe('configuration', () => { app.addEnvironment('MyEnv1'); app.addEnvironment('MyEnv2'); new HostedConfiguration(stack, 'MyHostedConfig', { - content: ConfigurationContent.fromInline('This is my content'), + content: ConfigurationContent.fromInlineText('This is my content'), application: app, deploymentStrategy: new DeploymentStrategy(stack, 'MyDeploymentStrategy', { rolloutStrategy: RolloutStrategy.linear({ @@ -108,7 +87,7 @@ describe('configuration', () => { Ref: 'MyHostedConfigConfigurationProfile2E1A2BBC', }, Content: 'This is my content', - ContentType: 'application/json', + ContentType: 'text/plain', }); Template.fromStack(stack).resourceCountIs('AWS::AppConfig::Environment', 2); Template.fromStack(stack).resourceCountIs('AWS::AppConfig::Deployment', 0); @@ -122,7 +101,7 @@ describe('configuration', () => { app.addEnvironment('MyEnv1'); const env = app.addEnvironment('MyEnv2'); new HostedConfiguration(stack, 'MyHostedConfig', { - content: ConfigurationContent.fromInline('This is my content'), + content: ConfigurationContent.fromInlineText('This is my content'), application: app, deployTo: [env], deploymentStrategy: new DeploymentStrategy(stack, 'MyDeploymentStrategy', { @@ -147,7 +126,7 @@ describe('configuration', () => { Ref: 'MyHostedConfigConfigurationProfile2E1A2BBC', }, Content: 'This is my content', - ContentType: 'application/json', + ContentType: 'text/plain', }); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::Deployment', { ApplicationId: { @@ -179,7 +158,7 @@ describe('configuration', () => { const env2 = app.addEnvironment('MyEnv2'); const bucket = new Bucket(stack, 'MyBucket'); new HostedConfiguration(stack, 'MyHostedConfig', { - content: ConfigurationContent.fromInline('This is my content'), + content: ConfigurationContent.fromInlineText('This is my content'), application: app, deployTo: [env1], deploymentStrategy: new DeploymentStrategy(stack, 'MyDeploymentStrategy1', { @@ -217,7 +196,7 @@ describe('configuration', () => { Ref: 'MyHostedConfigConfigurationProfile2E1A2BBC', }, Content: 'This is my content', - ContentType: 'application/json', + ContentType: 'text/plain', }); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::ConfigurationProfile', { Name: 'MySourcedConfig', @@ -292,7 +271,7 @@ describe('configuration', () => { }); const bucket = new Bucket(stack, 'MyBucket'); new HostedConfiguration(stack, 'MyHostedConfig', { - content: ConfigurationContent.fromInline('This is my content'), + content: ConfigurationContent.fromInlineText('This is my content'), application: app, }); new SourcedConfiguration(stack, 'MySourcedConfig', { @@ -333,6 +312,7 @@ describe('configuration', () => { deploymentDuration: cdk.Duration.minutes(30), }), }), + deployTo: [app.addEnvironment('Environment')], }); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::Deployment', { @@ -358,13 +338,14 @@ describe('configuration', () => { const app = new Application(stack, 'MyAppConfig'); new HostedConfiguration(stack, 'MyConfiguration', { application: app, - content: ConfigurationContent.fromInline('This is my content'), + content: ConfigurationContent.fromInlineText('This is my content'), deploymentStrategy: new DeploymentStrategy(stack, 'MyDeploymentStrategy', { rolloutStrategy: RolloutStrategy.linear({ growthFactor: 15, deploymentDuration: cdk.Duration.minutes(30), }), }), + deployTo: [app.addEnvironment('Environment')], }); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::ConfigurationProfile', { @@ -382,41 +363,76 @@ describe('configuration', () => { Ref: 'MyConfigurationConfigurationProfileEE0ECA85', }, Content: 'This is my content', - ContentType: 'application/json', + ContentType: 'text/plain', }); Template.fromStack(stack).resourceCountIs('AWS::AppConfig::Deployment', 1); }); - // test('default configuration from asset', () => { - // const stack = new cdk.Stack(); - // const app = new AppConfig(stack, 'MyAppConfig', { - // deploymentStrategy: new DeploymentStrategy(stack, 'MyDeploymentStrategy', { - // rolloutStrategy: RolloutStrategy.linear(15, cdk.Duration.minutes(30)), - // }), - // }); - // new HostedConfiguration(stack, 'MyConfiguration', { - // appConfig: app, - // content: ConfigurationContent.fromAsset('/Users/chenjane/Documents/appconfig-l2-constructs/test/config.json'), - // }); + test('default configuration from file', () => { + const stack = new cdk.Stack(); + const app = new Application(stack, 'MyAppConfig'); + new HostedConfiguration(stack, 'MyConfiguration', { + deploymentStrategy: new DeploymentStrategy(stack, 'MyDeploymentStrategy', { + rolloutStrategy: RolloutStrategy.linear({ + growthFactor: 15, + deploymentDuration: cdk.Duration.minutes(30), + }), + }), + application: app, + content: ConfigurationContent.fromFile('./test/config.json'), + }); - // Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::ConfigurationProfile', { - // Name: 'MyConfiguration', - // ApplicationId: { - // Ref: 'MyAppConfigB4B63E75', - // }, - // LocationUri: 'hosted', - // }); - // Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::HostedConfigurationVersion', { - // ApplicationId: { - // Ref: 'MyAppConfigB4B63E75', - // }, - // ConfigurationProfileId: { - // Ref: 'MyConfigurationConfigurationProfileEE0ECA85', - // }, - // Content: '{\n "content": "This is the configuration content"\n}', - // ContentType: 'application/json', - // }); - // }); + Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::ConfigurationProfile', { + Name: 'MyConfiguration', + ApplicationId: { + Ref: 'MyAppConfigB4B63E75', + }, + LocationUri: 'hosted', + }); + Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::HostedConfigurationVersion', { + ApplicationId: { + Ref: 'MyAppConfigB4B63E75', + }, + ConfigurationProfileId: { + Ref: 'MyConfigurationConfigurationProfileEE0ECA85', + }, + Content: '{\n "content": "This is the configuration content"\n}', + ContentType: 'application/json', + }); + }); + + test('default configuration from inline octet', () => { + const stack = new cdk.Stack(); + const app = new Application(stack, 'MyAppConfig'); + new HostedConfiguration(stack, 'MyConfiguration', { + deploymentStrategy: new DeploymentStrategy(stack, 'MyDeploymentStrategy', { + rolloutStrategy: RolloutStrategy.linear({ + growthFactor: 15, + deploymentDuration: cdk.Duration.minutes(30), + }), + }), + application: app, + content: ConfigurationContent.fromInline('This should be of content type application/octet'), + }); + + Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::ConfigurationProfile', { + Name: 'MyConfiguration', + ApplicationId: { + Ref: 'MyAppConfigB4B63E75', + }, + LocationUri: 'hosted', + }); + Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::HostedConfigurationVersion', { + ApplicationId: { + Ref: 'MyAppConfigB4B63E75', + }, + ConfigurationProfileId: { + Ref: 'MyConfigurationConfigurationProfileEE0ECA85', + }, + Content: 'This should be of content type application/octet', + ContentType: 'application/octet-stream', + }); + }); test('configuration profile with name', () => { const stack = new cdk.Stack(); @@ -424,7 +440,7 @@ describe('configuration', () => { new HostedConfiguration(stack, 'MyConfigurationProfile', { name: 'TestConfigProfile', application: app, - content: ConfigurationContent.fromInline('This is my content'), + content: ConfigurationContent.fromInlineText('This is my content'), deploymentStrategy: new DeploymentStrategy(stack, 'MyDeploymentStrategy', { rolloutStrategy: RolloutStrategy.linear({ growthFactor: 15, @@ -448,9 +464,9 @@ describe('configuration', () => { Ref: 'MyConfigurationProfile33A97163', }, Content: 'This is my content', - ContentType: 'application/json', + ContentType: 'text/plain', }); - Template.fromStack(stack).resourceCountIs('AWS::AppConfig::Deployment', 1); + Template.fromStack(stack).resourceCountIs('AWS::AppConfig::Deployment', 0); }); test('configuration profile with type', () => { @@ -460,7 +476,7 @@ describe('configuration', () => { name: 'TestConfigProfile', application: app, type: ConfigurationType.FEATURE_FLAGS, - content: ConfigurationContent.fromInline('This is my content'), + content: ConfigurationContent.fromInlineText('This is my content'), deploymentStrategy: new DeploymentStrategy(stack, 'MyDeploymentStrategy', { rolloutStrategy: RolloutStrategy.linear({ growthFactor: 15, @@ -485,9 +501,9 @@ describe('configuration', () => { Ref: 'MyConfigurationProfile33A97163', }, Content: 'This is my content', - ContentType: 'application/json', + ContentType: 'text/plain', }); - Template.fromStack(stack).resourceCountIs('AWS::AppConfig::Deployment', 1); + Template.fromStack(stack).resourceCountIs('AWS::AppConfig::Deployment', 0); }); test('configuration profile with description', () => { @@ -496,7 +512,7 @@ describe('configuration', () => { new HostedConfiguration(stack, 'MyConfigurationProfile', { name: 'TestConfigProfile', application: app, - content: ConfigurationContent.fromInline('This is my content'), + content: ConfigurationContent.fromInlineText('This is my content'), description: 'This is my description', deploymentStrategy: new DeploymentStrategy(stack, 'MyDeploymentStrategy', { rolloutStrategy: RolloutStrategy.linear({ @@ -522,10 +538,10 @@ describe('configuration', () => { Ref: 'MyConfigurationProfile33A97163', }, Content: 'This is my content', - ContentType: 'application/json', + ContentType: 'text/plain', Description: 'This is my description', }); - Template.fromStack(stack).resourceCountIs('AWS::AppConfig::Deployment', 1); + Template.fromStack(stack).resourceCountIs('AWS::AppConfig::Deployment', 0); }); test('configuration profile with validator', () => { @@ -534,7 +550,7 @@ describe('configuration', () => { new HostedConfiguration(stack, 'MyConfigurationProfile', { name: 'TestConfigProfile', application: app, - content: ConfigurationContent.fromInline('This is my content'), + content: ConfigurationContent.fromInlineText('This is my content'), validators: [ { content: 'dummy validator', @@ -570,9 +586,9 @@ describe('configuration', () => { Ref: 'MyConfigurationProfile33A97163', }, Content: 'This is my content', - ContentType: 'application/json', + ContentType: 'text/plain', }); - Template.fromStack(stack).resourceCountIs('AWS::AppConfig::Deployment', 1); + Template.fromStack(stack).resourceCountIs('AWS::AppConfig::Deployment', 0); }); test('configuration profile with inline json schema validator', () => { @@ -715,7 +731,7 @@ describe('configuration', () => { validators: [ JsonSchemaValidator.fromInline(validatorContent), ], - content: ConfigurationContent.fromInline('This is my content'), + content: ConfigurationContent.fromInlineText('This is my content'), deploymentStrategy: new DeploymentStrategy(stack, 'MyDeploymentStrategy', { rolloutStrategy: RolloutStrategy.linear({ growthFactor: 15, @@ -745,9 +761,9 @@ describe('configuration', () => { Ref: 'MyConfigurationConfigurationProfileEE0ECA85', }, Content: 'This is my content', - ContentType: 'application/json', + ContentType: 'text/plain', }); - Template.fromStack(stack).resourceCountIs('AWS::AppConfig::Deployment', 1); + Template.fromStack(stack).resourceCountIs('AWS::AppConfig::Deployment', 0); }); test('configuration profile with ssm parameter', () => { @@ -768,6 +784,7 @@ describe('configuration', () => { deploymentDuration: cdk.Duration.minutes(30), }), }), + deployTo: [app.addEnvironment('Environment')], }); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::ConfigurationProfile', { @@ -848,6 +865,7 @@ describe('configuration', () => { deploymentDuration: cdk.Duration.minutes(30), }), }), + deployTo: [app.addEnvironment('Environment')], }); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::ConfigurationProfile', { @@ -915,6 +933,7 @@ describe('configuration', () => { deploymentDuration: cdk.Duration.minutes(30), }), }), + deployTo: [app.addEnvironment('Environment')], }); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::ConfigurationProfile', { @@ -1030,6 +1049,7 @@ describe('configuration', () => { deploymentDuration: cdk.Duration.minutes(30), }), }), + deployTo: [app.addEnvironment('Environment')], }); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::ConfigurationProfile', { @@ -1074,6 +1094,7 @@ describe('configuration', () => { deploymentDuration: cdk.Duration.minutes(30), }), }), + deployTo: [app.addEnvironment('Environment')], }); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::ConfigurationProfile', { @@ -1125,6 +1146,7 @@ describe('configuration', () => { deploymentDuration: cdk.Duration.minutes(30), }), }), + deployTo: [app.addEnvironment('Environment')], }); Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::ConfigurationProfile', { diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/extension.test.ts b/packages/@aws-cdk/aws-appconfig-alpha/test/extension.test.ts index c4faed3acb4c3..7be5ace16bc12 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/extension.test.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/extension.test.ts @@ -497,7 +497,7 @@ describe('extension', () => { const app = new Application(stack, 'MyApplication'); const configProfile = new HostedConfiguration(stack, 'MyConfiguration', { application: app, - content: ConfigurationContent.fromInline('This is my content.'), + content: ConfigurationContent.fromInlineJson('This is my content.'), }); const ext = new Extension(stack, 'MyExtension', { actions: [ diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/aws-appconfig-configuration.assets.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/aws-appconfig-configuration.assets.json index e245698a2ce83..3f2c4e58bfe66 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/aws-appconfig-configuration.assets.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/aws-appconfig-configuration.assets.json @@ -53,7 +53,7 @@ } } }, - "62a9b3aeb4a84560d1814dd4ac31c12a8f5047e3cde5873f6f4c351d7668af04": { + "76b9cabe996a7bad89a83038f1c4375968b6a16e8f5f1e2ce353b667d8576cbe": { "source": { "path": "aws-appconfig-configuration.template.json", "packaging": "file" @@ -61,7 +61,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "62a9b3aeb4a84560d1814dd4ac31c12a8f5047e3cde5873f6f4c351d7668af04.json", + "objectKey": "76b9cabe996a7bad89a83038f1c4375968b6a16e8f5f1e2ce353b667d8576cbe.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.configuration.js.snapshot/aws-appconfig-configuration.template.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/aws-appconfig-configuration.template.json index b1eda3c6e7502..6dbdcb9b930ac 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/aws-appconfig-configuration.template.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/aws-appconfig-configuration.template.json @@ -105,7 +105,7 @@ "Ref": "MyHostedConfigConfigurationProfile2E1A2BBC" }, "Content": "This is my configuration content.", - "ContentType": "application/json" + "ContentType": "text/plain" }, "UpdateReplacePolicy": "Retain", "DeletionPolicy": "Retain" @@ -150,7 +150,7 @@ "Ref": "MyHostedConfigFromJsonConfigurationProfile863E1E42" }, "Content": "This is the configuration content", - "ContentType": "application/json" + "ContentType": "text/plain" }, "UpdateReplacePolicy": "Retain", "DeletionPolicy": "Retain" diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/manifest.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/manifest.json index 745926ca84296..803f0bed5f4f7 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/manifest.json @@ -17,7 +17,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}/62a9b3aeb4a84560d1814dd4ac31c12a8f5047e3cde5873f6f4c351d7668af04.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/76b9cabe996a7bad89a83038f1c4375968b6a16e8f5f1e2ce353b667d8576cbe.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/tree.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/tree.json index 0f0a957f37369..df892fd33b39c 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/tree.json @@ -49,7 +49,7 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.Resource", + "fqn": "@aws-cdk/aws-appconfig-alpha.Environment", "version": "0.0.0" } }, @@ -76,7 +76,7 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.Resource", + "fqn": "@aws-cdk/aws-appconfig-alpha.Environment", "version": "0.0.0" } }, @@ -103,7 +103,7 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.Resource", + "fqn": "@aws-cdk/aws-appconfig-alpha.Environment", "version": "0.0.0" } }, @@ -130,7 +130,7 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.Resource", + "fqn": "@aws-cdk/aws-appconfig-alpha.Environment", "version": "0.0.0" } }, @@ -157,7 +157,7 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.Resource", + "fqn": "@aws-cdk/aws-appconfig-alpha.Environment", "version": "0.0.0" } }, @@ -184,7 +184,7 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.Resource", + "fqn": "@aws-cdk/aws-appconfig-alpha.Environment", "version": "0.0.0" } }, @@ -211,13 +211,13 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.Resource", + "fqn": "@aws-cdk/aws-appconfig-alpha.Environment", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "aws-cdk-lib.Resource", + "fqn": "@aws-cdk/aws-appconfig-alpha.Application", "version": "0.0.0" } }, @@ -245,7 +245,7 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.Resource", + "fqn": "@aws-cdk/aws-appconfig-alpha.DeploymentStrategy", "version": "0.0.0" } }, @@ -290,7 +290,7 @@ "Ref": "MyHostedConfigConfigurationProfile2E1A2BBC" }, "content": "This is my configuration content.", - "contentType": "application/json" + "contentType": "text/plain" } }, "constructInfo": { @@ -328,8 +328,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.69" + "fqn": "@aws-cdk/aws-appconfig-alpha.HostedConfiguration", + "version": "0.0.0" } }, "MyHostedConfigFromJson": { @@ -367,7 +367,7 @@ "Ref": "MyHostedConfigFromJsonConfigurationProfile863E1E42" }, "content": "This is the configuration content", - "contentType": "application/json" + "contentType": "text/plain" } }, "constructInfo": { @@ -405,8 +405,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.69" + "fqn": "@aws-cdk/aws-appconfig-alpha.HostedConfiguration", + "version": "0.0.0" } }, "MyValidatorFunction": { @@ -717,8 +717,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.69" + "fqn": "@aws-cdk/aws-appconfig-alpha.SourcedConfiguration", + "version": "0.0.0" } }, "MyDocument": { @@ -897,8 +897,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.69" + "fqn": "@aws-cdk/aws-appconfig-alpha.SourcedConfiguration", + "version": "0.0.0" } }, "MyBucket": { @@ -1349,7 +1349,7 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.Resource", + "fqn": "@aws-cdk/aws-appconfig-alpha.DeploymentStrategy", "version": "0.0.0" } }, @@ -1515,8 +1515,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.69" + "fqn": "@aws-cdk/aws-appconfig-alpha.SourcedConfiguration", + "version": "0.0.0" } }, "MySecret": { @@ -1572,7 +1572,7 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.Resource", + "fqn": "@aws-cdk/aws-appconfig-alpha.DeploymentStrategy", "version": "0.0.0" } }, @@ -1664,8 +1664,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.69" + "fqn": "@aws-cdk/aws-appconfig-alpha.SourcedConfiguration", + "version": "0.0.0" } }, "MyKey": { @@ -1824,7 +1824,7 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.Resource", + "fqn": "@aws-cdk/aws-appconfig-alpha.DeploymentStrategy", "version": "0.0.0" } }, @@ -1926,8 +1926,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.69" + "fqn": "@aws-cdk/aws-appconfig-alpha.SourcedConfiguration", + "version": "0.0.0" } }, "MyPipeline": { @@ -2787,7 +2787,7 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.Resource", + "fqn": "@aws-cdk/aws-appconfig-alpha.DeploymentStrategy", "version": "0.0.0" } }, @@ -2821,8 +2821,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.69" + "fqn": "@aws-cdk/aws-appconfig-alpha.SourcedConfiguration", + "version": "0.0.0" } }, "BootstrapVersion": { 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 5722d6ae23a7f..ff28df311f576 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.ts @@ -52,7 +52,7 @@ const deploymentStrategy = new DeploymentStrategy(stack, 'MyDeployStrategy', { const hostedEnv = appConfigApp.addEnvironment('HostedEnv'); new HostedConfiguration(stack, 'MyHostedConfig', { application: appConfigApp, - content: ConfigurationContent.fromInline('This is my configuration content.'), + content: ConfigurationContent.fromInlineText('This is my configuration content.'), deployTo: [hostedEnv], validators: [ JsonSchemaValidator.fromInline(SCHEMA_STR), @@ -65,7 +65,7 @@ new HostedConfiguration(stack, 'MyHostedConfig', { const hostedEnvFromJson = appConfigApp.addEnvironment('HostedEnvFromJson'); new HostedConfiguration(stack, 'MyHostedConfigFromJson', { application: appConfigApp, - content: ConfigurationContent.fromInline('This is the configuration content'), + content: ConfigurationContent.fromInlineText('This is the configuration content'), deployTo: [hostedEnvFromJson], deploymentStrategy, }); 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 65ff5986da603..7e6becd0d0e90 100755 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.ts @@ -102,7 +102,7 @@ app.addExtension(busExtension); const env = app.addEnvironment('MyEnv'); const hostedConfig = new HostedConfiguration(stack, 'HostedConfiguration', { application: app, - content: ConfigurationContent.fromInline('This is my configuration content'), + content: ConfigurationContent.fromInlineJson('This is my configuration content'), deployTo: [env], deploymentStrategy: new DeploymentStrategy(stack, 'MyDeployStrategy', { rolloutStrategy: RolloutStrategy.linear({ From 4cef10b59a9b2414220222634d28fd7fa4599321 Mon Sep 17 00:00:00 2001 From: Jane Chen Date: Tue, 15 Aug 2023 21:16:22 -0400 Subject: [PATCH 2/3] Update yarn.lock with mime-types --- yarn.lock | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/yarn.lock b/yarn.lock index c48c1c79f16eb..17094a48597a4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3873,6 +3873,11 @@ resolved "https://registry.npmjs.org/@types/md5/-/md5-2.3.2.tgz#529bb3f8a7e9e9f621094eb76a443f585d882528" integrity sha512-v+JFDu96+UYJ3/UWzB0mEglIS//MZXgRaJ4ubUPwOM0gvLc/kcQ3TWNYwENEK7/EcXGQVrW8h/XqednSjBd/Og== +"@types/mime-types@^2.1.1": + version "2.1.1" + resolved "https://registry.npmjs.org/@types/mime-types/-/mime-types-2.1.1.tgz#d9ba43490fa3a3df958759adf69396c3532cf2c1" + integrity sha512-vXOTGVSLR2jMw440moWTC7H19iUyLtP3Z1YTj7cSsubOICinjMxFeb/V57v9QdyyPGbbWolUFSSmSiRSn94tFw== + "@types/mime@^2.0.3": version "2.0.3" resolved "https://registry.npmjs.org/@types/mime/-/mime-2.0.3.tgz#c893b73721db73699943bfc3653b1deb7faa4a3a" @@ -8855,7 +8860,7 @@ jest-worker@^29.6.2: merge-stream "^2.0.0" supports-color "^8.0.0" -jest@^29, jest@^29.6.2: +jest@^29, jest@^29.6.1, jest@^29.6.2: version "29.6.2" resolved "https://registry.npmjs.org/jest/-/jest-29.6.2.tgz#3bd55b9fd46a161b2edbdf5f1d1bd0d1eab76c42" integrity sha512-8eQg2mqFbaP7CwfsTpCxQ+sHzw1WuNWL5UUvjnWP4hx2riGz9fPSzYOaU5q8/GqWn1TfgZIVTqYJygbGbWAANg== @@ -9910,7 +9915,7 @@ mime-db@1.52.0: resolved "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== -mime-types@^2.1.12: +mime-types@^2.1.12, mime-types@^2.1.35: version "2.1.35" resolved "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== From c68625204333bf2dd33f19c2e6b71c2d4b886c2a Mon Sep 17 00:00:00 2001 From: Jane Chen Date: Wed, 16 Aug 2023 10:31:15 -0400 Subject: [PATCH 3/3] Add mime-types and mime-db to NOTICE --- packages/@aws-cdk/aws-appconfig-alpha/NOTICE | 32 ++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/packages/@aws-cdk/aws-appconfig-alpha/NOTICE b/packages/@aws-cdk/aws-appconfig-alpha/NOTICE index a27b7dd317649..b1adfdf58a098 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/NOTICE +++ b/packages/@aws-cdk/aws-appconfig-alpha/NOTICE @@ -1,2 +1,34 @@ AWS Cloud Development Kit (AWS CDK) Copyright 2018-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. + +------------------------------------------------------------------------------- + +The AWS CDK includes the following third-party software/licensing: + +** mime-db - https://www.npmjs.com/package/mime-db +** mime-types - https://www.npmjs.com/package/mime-types +(The MIT License) + +Copyright (c) 2014 Jonathan Ong +Copyright (c) 2015-2022 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +----------------