Reputation: 11
I am trying to create an AWS AppConfig app, configuration profile, environment, hosted configuration, deployment strategy and the deployment constructs from CDK V1 (Node.js).
I am following @aws-cdk_aws-appconfig.CfnHostedConfigurationVersion AWS docs. Unfortunately, no specification has been given on content syntax.
While performing cdk deploy
it gives an error:
MyCfnHostedConfigurationVersion Error invoking extension AppConfig Feature Flags Helper: Malformed 'Content' provided (Service: AmazonAppConfig; Status Code: 400; Error Code: BadRequestException; Request ID: f9496e9f-db25-438b-a7bb-f030351eb251; Proxy: null)
I am trying to apply Aleksander Gurin's solution. I am using CDK V1 (Node.Js).
Code I have tried so far. I expected it to create the AppConfig profile of feature flags type.
//Create an application
const cfnAppConfigApplication = new appconfig.CfnApplication(this, 'MyCfnApplication', { name: 'document-vault-app-config-app', description: 'App to maintain environment variables for Document Vault.',});
//Create an environment
const cfnEnvironment = new appconfig.CfnEnvironment(this, 'MyCfnEnvironment', {
applicationId: cfnAppConfigApplication.ref,
name: props.environmentName,
description: 'Environment to deploy the configuration to.',
});
//Create a configuration profile
const cfnConfigurationProfile = new appconfig.CfnConfigurationProfile(this, 'MyCfnConfigurationProfile', {
applicationId: cfnAppConfigApplication.ref,
locationUri: 'hosted',
name: 'cp-migration-feature-flag-app-config-profile',
// the properties below are optional
description: 'Profile to store CP migration feature flags.',
type: 'AWS.AppConfig.FeatureFlags'
});
const configVersion = Date.now();
const base64FeatureFlagsContent = Buffer.from(JSON.stringify(
{
"flags": {
"flagkey": {
"name": "cp_migration_feature_flags"
}
},
"values": {
"flagkey": {
"enabled": false
}
},
"version": "1"
}
)).toString('base64');
const cfnHostedConfigurationVersion = new appconfig.CfnHostedConfigurationVersion(this, 'MyCfnHostedConfigurationVersion', {
applicationId: cfnAppConfigApplication.ref,
configurationProfileId: cfnConfigurationProfile.ref,
content: base64FeatureFlagsContent,
contentType: 'application/json',
// the properties below are optional
description: 'Hosted configuration for CP migration feature flags.',
latestVersionNumber: 1,
});
//Create a deployment strategy
const cfnDeploymentStrategy = new appconfig.CfnDeploymentStrategy(this, 'MyCfnDeploymentStrategy', {
deploymentDurationInMinutes: 3,
growthFactor: 100,
name: 'document-vault-app-deployment-strategy',
replicateTo: 'NONE',
description: 'Strategy to deploy document vault configuration',
finalBakeTimeInMinutes: 4,
growthType: 'LINEAR'
});
const cfnDeployment = new appconfig.CfnDeployment(this, 'MyCfnDeployment', {
applicationId: cfnAppConfigApplication.ref,
configurationProfileId: cfnConfigurationProfile.ref,
configurationVersion: "1",
deploymentStrategyId: cfnDeploymentStrategy.ref,
environmentId: cfnEnvironment.ref,
// the properties below are optional
description: 'Deployment of document vault configuration',
});
Upvotes: 1
Views: 352