AWSAWS CDK

Set “AWS::CloudFormation::Interface” in your AWS CDK code (For TypeScript)

AWS CDK has not supported the parameter AWS::CloudFormation::Interface. We don’t currently have a plan f […]

広告ここから
広告ここまで

AWS CDK has not supported the parameter AWS::CloudFormation::Interface.

We don’t currently have a plan for first-class support for AWS::CloudFormation::Interface but it shouldn’t be too hard to synthesize this metadata:

https://github.com/aws/aws-cdk/issues/5944

Solution: use templateOptions.metadata instead

We can define the parameter by using the templateOptions.metadata parameter.


export class CfStackStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);
    
    // params
    const originDomain = new cdk.CfnParameter(this, 'OriginDomain', {
      type: 'String',
      description: 'Website url'
    })
    this.templateOptions.metadata = {
      "AWS::CloudFormation::Interface": {
        ParameterGroups: [
          {
            Label: {
              default: "Example interface"
            },
            Parameters: [
              'OriginDomain'
            ]
          },
        ]
      }
    }
....

enum helps us to handle the parameter ID

We have to put the parameter ID at least two times when using Interface. It’s possible to miss the ID.

To define the IDs by using enum is helps us to handle it more easily.

enum CfnParameterName {
   OriginDomain = 'OriginDomain'
}

export class CfStackStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);
    
    // params
    const originDomain = new cdk.CfnParameter(this, CfnParameterName.OriginDomain, {
      type: 'String',
      description: 'Website url'
    })
    this.templateOptions.metadata = {
      "AWS::CloudFormation::Interface": {
        ParameterGroups: [
          {
            Label: {
              default: "Example interface"
            },
            Parameters: [
              CfnParameterName.OriginDomain
            ]
          },
        ]
      }
    }
....

ブックマークや限定記事(予定)など

WP Kyotoサポーター募集中

WordPressやフロントエンドアプリのホスティング、Algolia・AWSなどのサービス利用料を支援する「WP Kyotoサポーター」を募集しています。
月額または年額の有料プランを契約すると、ブックマーク機能などのサポーター限定機能がご利用いただけます。

14日間のトライアルも用意しておりますので、「このサイトよく見るな」という方はぜひご検討ください。

広告ここから
広告ここまで

Related Category posts