Skip to content

Commit

Permalink
feat(appconfig): inline YAML support for hosted configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjane-dev committed Oct 26, 2023
1 parent 05f3453 commit 53c6b2c
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/@aws-cdk/aws-appconfig-alpha/lib/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,18 @@ export abstract class ConfigurationContent {
};
}

/**
* Defines the hosted configuration content as YAML from inline code.
*
* @param content The inline code that defines the configuration content
*/
public static fromInlineYaml(content: string): ConfigurationContent {
return {
content,
contentType: 'application/x-yaml',
};
}

/**
* The configuration content.
*/
Expand Down
33 changes: 33 additions & 0 deletions packages/@aws-cdk/aws-appconfig-alpha/test/configuration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,39 @@ describe('configuration', () => {
});
});

test('default configuration from inline yaml', () => {
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.fromInlineYaml('This should be of content type application/x-yaml'),
});

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/x-yaml',
ContentType: 'application/x-yaml',
});
});

test('configuration profile with name', () => {
const stack = new cdk.Stack();
const app = new Application(stack, 'MyAppConfig');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ new HostedConfiguration(stack, 'MyHostedConfigFromJson', {
deploymentStrategy,
});

const hostedEnvFromYaml = appConfigApp.addEnvironment('HostedEnvFromYaml');
new HostedConfiguration(stack, 'MyHostedConfigFromYaml', {
application: appConfigApp,
content: ConfigurationContent.fromInlineYaml('This is the configuration content'),
deployTo: [hostedEnvFromYaml],
deploymentStrategy,
});

// ssm paramter as configuration source
const func = new Function(stack, 'MyValidatorFunction', {
runtime: Runtime.PYTHON_3_8,
Expand Down

0 comments on commit 53c6b2c

Please sign in to comment.