DEV Community

Cover image for  AWS CDK  Escape Hatches in GO-CDK
Gernot Glawe
Gernot Glawe

Posted on

AWS CDK Escape Hatches in GO-CDK

With a hint from the jssi issues, I finally managed the CDK escape hatches - https://docs.aws.amazon.com/cdk/v2/guide/cfn_layer.html in GO.

Basic idea is to replace the "any" types defined in the CDK/jsii like:

type CfnBucket_AnalyticsConfigurationProperty struct {
    Id *string `json:"id" yaml:"id"`
    StorageClassAnalysis interface{} `json:"storageClassAnalysis" yaml:"storageClassAnalysis"`
    Prefix *string `json:"prefix" yaml:"prefix"`
    TagFilters interface{} `json:"tagFilters" yaml:"tagFilters"`
}
Enter fullscreen mode Exit fullscreen mode

With GoFormation structures, which include all type informations like:

// See: 
type Bucket_AnalyticsConfiguration struct {
    Id string `json:"Id,omitempty"`
    Prefix string `json:"Prefix,omitempty"`
    StorageClassAnalysis *Bucket_StorageClassAnalysis `json:"StorageClassAnalysis,omitempty"`
Enter fullscreen mode Exit fullscreen mode

And get rid of the interface{}.

So: Want to use AWS CDK Escape Hatches as direct Cfnxx Construct modification easy and type-safe in GO-CDK?
Details here:
https://www.go-on-aws.com/infrastructure-as-go/cdk-go/escape-hatches/
Image description

What do you think about the methods?

aws #cdk #golang #cloudformation

Top comments (0)