AWS AppConfig Extension use with CDK

0

I have created an Application, Environment, ConfigurationProfile using CDK constructs. Now i am not getting how to use CDK to add extension to the AppConfig Application, Environment, Configuration Profile.

There is no function mentioned anywhere in L1 constructs which can be used to add extension on the configuration profile.

This is the extension reference in cloud formation https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appconfig-extension.html

1개 답변
0

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.

AWS
답변함 일 년 전
  • Thanks for the reference. I ran the above without extension key. It worked fine. As I added 'appconfig.CfnConfigurationProfile.ExtensionsProperty' key, with value as

    
    {
    	"ContentType":"application/json",
    	"Content":{
    		"ExtensionIdentifier": "AWS.AppConfig.DeploymentNotificationsToSns",
    		"Parameters":{
    			"topicArn": "arn:aws:sns:us-west-2:111222333444:AppConfigNotifyTopic"
    		}
    	}	
    }
    
    

    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

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠