cdk-import
Generates CDK L1 constructs for public CloudFormation Registry types and modules.
NOTE: This is part of the implementation of RFC
Installation
$ npm install -g cdk-import
Usage
$ cdk-import --help
Usage: cdk-import RESOURCE-NAME[@VERSION]
Options:
-o, --outdir Output directory [string] [default: "src"]
Examples:
cdk-import AWSQS::EKS::Cluster Generates an L1 construct for the latest version of this resource under src/awsqs-eks-cluster.ts
cdk-import AWSQS::EKS::Cluster@1.2.0 Generates an L1 construct for a specific version
This command will query the AWS CloudFormation Registry and will generate L1 constructs for the specified resource. If a version
is not specified, the latest version will be selected. Otherwise, the specific version will be used.
For example:
$ cdk-import AWSQS::EKS::Cluster
src/awsqs-eks-cluster.ts
import * as cdk from '@aws-cdk/core';
export interface CfnClusterProps {
readonly name?: string;
readonly roleArn: string;
readonly lambdaRoleName?: string;
readonly version?: string;
readonly kubernetesNetworkConfig?: CfnClusterPropsKubernetesNetworkConfig;
readonly resourcesVpcConfig: CfnClusterPropsResourcesVpcConfig;
readonly enabledClusterLoggingTypes?: string[];
readonly encryptionConfig?: EncryptionConfigEntry[];
readonly kubernetesApiAccess?: CfnClusterPropsKubernetesApiAccess;
readonly tags?: CfnClusterPropsTags[];
}
export function toJson_CfnClusterProps(obj: CfnClusterProps | undefined): Record<string, any> | undefined {
if (obj === undefined) { return undefined; }
const result = {
'Name': obj.name,
'RoleArn': obj.roleArn,
'LambdaRoleName': obj.lambdaRoleName,
'Version': obj.version,
'KubernetesNetworkConfig': toJson_CfnClusterPropsKubernetesNetworkConfig(obj.kubernetesNetworkConfig),
'ResourcesVpcConfig': toJson_CfnClusterPropsResourcesVpcConfig(obj.resourcesVpcConfig),
'EnabledClusterLoggingTypes': obj.enabledClusterLoggingTypes?.map(y => y),
'EncryptionConfig': obj.encryptionConfig?.map(y => toJson_EncryptionConfigEntry(y)),
'KubernetesApiAccess': toJson_CfnClusterPropsKubernetesApiAccess(obj.kubernetesApiAccess),
'Tags': obj.tags?.map(y => toJson_CfnClusterPropsTags(y)),
};
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
}
export interface CfnClusterPropsKubernetesNetworkConfig {
readonly serviceIpv4Cidr?: string;
}
export function toJson_CfnClusterPropsKubernetesNetworkConfig(obj: CfnClusterPropsKubernetesNetworkConfig | undefined): Record<string, any> | undefined {
if (obj === undefined) { return undefined; }
const result = {
'ServiceIpv4Cidr': obj.serviceIpv4Cidr,
};
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
}
export interface CfnClusterPropsResourcesVpcConfig {
readonly securityGroupIds?: string[];
readonly subnetIds: string[];
readonly endpointPublicAccess?: boolean;
readonly endpointPrivateAccess?: boolean;
readonly publicAccessCidrs?: string[];
}
export function toJson_CfnClusterPropsResourcesVpcConfig(obj: CfnClusterPropsResourcesVpcConfig | undefined): Record<string, any> | undefined {
if (obj === undefined) { return undefined; }
const result = {
'SecurityGroupIds': obj.securityGroupIds?.map(y => y),
'SubnetIds': obj.subnetIds?.map(y => y),
'EndpointPublicAccess': obj.endpointPublicAccess,
'EndpointPrivateAccess': obj.endpointPrivateAccess,
'PublicAccessCidrs': obj.publicAccessCidrs?.map(y => y),
};
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
}
export interface EncryptionConfigEntry {
readonly resources?: string[];
readonly provider?: Provider;
}
export function toJson_EncryptionConfigEntry(obj: EncryptionConfigEntry | undefined): Record<string, any> | undefined {
if (obj === undefined) { return undefined; }
const result = {
'Resources': obj.resources?.map(y => y),
'Provider': toJson_Provider(obj.provider),
};
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
}
export interface CfnClusterPropsKubernetesApiAccess {
readonly roles?: KubernetesApiAccessEntry[];
readonly users?: KubernetesApiAccessEntry[];
}
export function toJson_CfnClusterPropsKubernetesApiAccess(obj: CfnClusterPropsKubernetesApiAccess | undefined): Record<string, any> | undefined {
if (obj === undefined) { return undefined; }
const result = {
'Roles': obj.roles?.map(y => toJson_KubernetesApiAccessEntry(y)),
'Users': obj.users?.map(y => toJson_KubernetesApiAccessEntry(y)),
};
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
}
export interface CfnClusterPropsTags {
readonly value: string;
readonly key: string;
}
export function toJson_CfnClusterPropsTags(obj: CfnClusterPropsTags | undefined): Record<string, any> | undefined {
if (obj === undefined) { return undefined; }
const result = {
'Value': obj.value,
'Key': obj.key,
};
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
}
export interface Provider {
readonly keyArn?: string;
}
export function toJson_Provider(obj: Provider | undefined): Record<string, any> | undefined {
if (obj === undefined) { return undefined; }
const result = {
'KeyArn': obj.keyArn,
};
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
}
export interface KubernetesApiAccessEntry {
readonly arn?: string;
readonly username?: string;
readonly groups?: string[];
}
export function toJson_KubernetesApiAccessEntry(obj: KubernetesApiAccessEntry | undefined): Record<string, any> | undefined {
if (obj === undefined) { return undefined; }
const result = {
'Arn': obj.arn,
'Username': obj.username,
'Groups': obj.groups?.map(y => y),
};
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
}
export class CfnCluster extends cdk.CfnResource {
public static readonly CFN_RESOURCE_TYPE_NAME = \\"AWSQS::EKS::Cluster\\";
public readonly name: string | undefined;
public readonly roleArn: string;
public readonly lambdaRoleName: string | undefined;
public readonly version: string | undefined;
public readonly kubernetesNetworkConfig: any | undefined;
public readonly resourcesVpcConfig: any;
public readonly enabledClusterLoggingTypes: string[] | undefined;
public readonly encryptionConfig: EncryptionConfigEntry[] | undefined;
public readonly kubernetesApiAccess: any | undefined;
public readonly tags: any[] | undefined;
public readonly attrArn: string;
public readonly attrEndpoint: string;
public readonly attrClusterSecurityGroupId: string;
public readonly attrCertificateAuthorityData: string;
public readonly attrEncryptionConfigKeyArn: string;
public readonly attrOidcIssuerUrl: string;
constructor(scope: cdk.Construct, id: string, props: CfnClusterProps) {
super(scope, id, { type: CfnCluster.CFN_RESOURCE_TYPE_NAME, properties: toJson_CfnClusterProps(props)! });
this.name = props.name;
this.roleArn = props.roleArn;
this.lambdaRoleName = props.lambdaRoleName;
this.version = props.version;
this.kubernetesNetworkConfig = props.kubernetesNetworkConfig;
this.resourcesVpcConfig = props.resourcesVpcConfig;
this.enabledClusterLoggingTypes = props.enabledClusterLoggingTypes;
this.encryptionConfig = props.encryptionConfig;
this.kubernetesApiAccess = props.kubernetesApiAccess;
this.tags = props.tags;
this.attrArn = cdk.Token.asString(this.getAtt('Arn'));
this.attrEndpoint = cdk.Token.asString(this.getAtt('Endpoint'));
this.attrClusterSecurityGroupId = cdk.Token.asString(this.getAtt('ClusterSecurityGroupId'));
this.attrCertificateAuthorityData = cdk.Token.asString(this.getAtt('CertificateAuthorityData'));
this.attrEncryptionConfigKeyArn = cdk.Token.asString(this.getAtt('EncryptionConfigKeyArn'));
this.attrOidcIssuerUrl = cdk.Token.asString(this.getAtt('OIDCIssuerURL'));
}
}
Modules are also supported:
$ cdk-import AWSQS::CheckPoint::CloudGuardQS::MODULE
src/awsqs-checkpoint-cloudguardqs-module.ts
Roadmap
Contributing
See CONTRIBUTING
Security
See CONTRIBUTING for more information.
License
This project is licensed under the Apache-2.0 License.