- Newest
- Most votes
- Most comments
CDK provides support for most AWS resources and their properties, but some resources might not have corresponding L1 constructs. In such cases, you can use CfnResource to create the resource directly using its CloudFormation resource type.
To add an extension to an AppConfig ConfigurationProfile using CDK, you can create a CfnResource for the AWS::AppConfig::ConfigurationProfile resource type and set the Properties to include the extension reference. Here is an example:
import * as cdk from 'aws-cdk-lib'; import * as appconfig from 'aws-cdk-lib/aws-appconfig'; import * as cfn from 'aws-cdk-lib/aws-cloudformation';
const app = new cdk.App(); const stack = new cdk.Stack(app, 'MyStack');
const appConfigApp = new appconfig.CfnApplication(stack, 'MyAppConfigApp', { name: 'my-appconfig-app' });
const appConfigEnv = new appconfig.CfnEnvironment(stack, 'MyAppConfigEnv', { applicationId: appConfigApp.ref, name: 'my-appconfig-env' });
const appConfigProfile = new cfn.CfnResource(stack, 'MyAppConfigProfile', { type: 'AWS::AppConfig::ConfigurationProfile', properties: { ApplicationId: appConfigApp.ref, LocationUri: 's3://my-bucket/my-config.json', Name: 'my-appconfig-profile', Description: 'My AppConfig Profile', Tags: [ { Key: 'Environment', Value: 'Prod' } ], Retries: { Attempts: 3 }, Validators: [ { Type: 'JSON_SCHEMA', Content: '{"$schema": "http://json-schema.org/draft-04/schema#","type": "object","properties": {"foo": {"type": "string"}},"required": ["foo"],"additionalProperties": false}' } ], LatestVersionNumber: 1, Description: 'My AppConfig Profile', ContentType: 'application/json', Tags: [ { Key: 'Environment', Value: 'Prod' } ], // Here is the extension reference [appconfig.CfnConfigurationProfile.ExtensionsProperty]: [ { ContentType: 'application/json', Content: '{ "some_key": "some_value" }' } ] } });
app.synth();
This code creates an AppConfig ConfigurationProfile with an extension included. The Extensions property is set using the appconfig.CfnConfigurationProfile.ExtensionsProperty property key. The Content of the extension is set as a JSON string.
You can modify the Content of the extension as per your requirements.
Relevant content
- asked a year ago
- asked 2 years ago
- asked a month ago
- AWS OFFICIALUpdated 9 months ago
- AWS OFFICIALUpdated 4 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
Thanks for the reference. I ran the above without extension key. It worked fine. As I added 'appconfig.CfnConfigurationProfile.ExtensionsProperty' key, with value as
Json I have created Pojo and then passed to the key I am getting error Property validation failure: [Encountered unsupported properties in {/}: [appconfig.CfnConfigurationProfile.ExtensionsProperty]]
Can you check and provide the doc or correct key value