Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(appconfig): inline YAML support for hosted configuration #27696

Merged
merged 6 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/@aws-cdk/aws-appconfig-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ new appconfig.HostedConfiguration(this, 'MyHostedConfiguration', {
});
```

You can define hosted configuration content using any of the following ConfigurationContent methods:

* `fromFile` - Defines the hosted configuration content from a file.
* `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.

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.
Expand Down
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
"Name": "awsappconfigconfiguration-MyAppConfig-HostedEnvFromJson-140D2DDD"
}
},
"MyAppConfigHostedEnvFromYaml82D3D1B2": {
"Type": "AWS::AppConfig::Environment",
"Properties": {
"ApplicationId": {
"Ref": "MyAppConfigB4B63E75"
},
"Name": "awsappconfigconfiguration-MyAppConfig-HostedEnvFromYaml-BB2C802A"
}
},
"MyAppConfigParameterEnvD769FB19": {
"Type": "AWS::AppConfig::Environment",
"Properties": {
Expand Down Expand Up @@ -175,6 +184,51 @@
}
}
},
"MyHostedConfigFromYamlConfigurationProfile7C77A435": {
"Type": "AWS::AppConfig::ConfigurationProfile",
"Properties": {
"ApplicationId": {
"Ref": "MyAppConfigB4B63E75"
},
"LocationUri": "hosted",
"Name": "awsappconfigconfiguration-MyHostedConfigFromYaml-87E9786A"
}
},
"MyHostedConfigFromYaml13C5BE35": {
"Type": "AWS::AppConfig::HostedConfigurationVersion",
"Properties": {
"ApplicationId": {
"Ref": "MyAppConfigB4B63E75"
},
"ConfigurationProfileId": {
"Ref": "MyHostedConfigFromYamlConfigurationProfile7C77A435"
},
"Content": "This is the configuration content",
"ContentType": "application/x-yaml"
},
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain"
},
"MyHostedConfigFromYamlDeploymentFE9624CBE5FC6": {
"Type": "AWS::AppConfig::Deployment",
"Properties": {
"ApplicationId": {
"Ref": "MyAppConfigB4B63E75"
},
"ConfigurationProfileId": {
"Ref": "MyHostedConfigFromYamlConfigurationProfile7C77A435"
},
"ConfigurationVersion": {
"Ref": "MyHostedConfigFromYaml13C5BE35"
},
"DeploymentStrategyId": {
"Ref": "MyDeployStrategy062CAEA2"
},
"EnvironmentId": {
"Ref": "MyAppConfigHostedEnvFromYaml82D3D1B2"
}
}
},
"MyValidatorFunctionServiceRole5CD02390": {
"Type": "AWS::IAM::Role",
"Properties": {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading