Skip to content

Instantly share code, notes, and snippets.

@moofish32
Last active June 17, 2019 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moofish32/756853c8d53dc47c91dd321bace9ec17 to your computer and use it in GitHub Desktop.
Save moofish32/756853c8d53dc47c91dd321bace9ec17 to your computer and use it in GitHub Desktop.
// Copyright 2012-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// Generated from the AWS CloudFormation Resource Specification
// See: docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-resource-specification.html
// @cfn2ts:meta@ {"generated":"2019-06-17T20:08:04.438Z","fingerprint":"RRaQrKXriTRnT5GDKdzJRqLngFMESa0HgUFjHJUl2rM="}
// tslint:disable:max-line-length | This is generated code - line lengths are difficult to control
import cdk = require('@aws-cdk/cdk');
/**
* Properties for defining a `AWS::KMS::Alias`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-alias.html
*/
export interface CfnAliasProps {
/**
* `AWS::KMS::Alias.AliasName`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-alias.html#cfn-kms-alias-aliasname
*/
readonly aliasName: string;
/**
* `AWS::KMS::Alias.TargetKeyId`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-alias.html#cfn-kms-alias-targetkeyid
*/
readonly targetKeyId: string;
}
/**
* Determine whether the given properties match those of a `CfnAliasProps`
*
* @param properties - the TypeScript properties of a `CfnAliasProps`
*
* @returns the result of the validation.
*/
function CfnAliasPropsValidator(properties: any): cdk.ValidationResult {
if (!cdk.canInspect(properties)) { return cdk.VALIDATION_SUCCESS; }
const errors = new cdk.ValidationResults();
errors.collect(cdk.propertyValidator('aliasName', cdk.requiredValidator)(properties.aliasName));
errors.collect(cdk.propertyValidator('aliasName', cdk.validateString)(properties.aliasName));
errors.collect(cdk.propertyValidator('targetKeyId', cdk.requiredValidator)(properties.targetKeyId));
errors.collect(cdk.propertyValidator('targetKeyId', cdk.validateString)(properties.targetKeyId));
return errors.wrap('supplied properties not correct for "CfnAliasProps"');
}
/**
* Renders the AWS CloudFormation properties of an `AWS::KMS::Alias` resource
*
* @param properties - the TypeScript properties of a `CfnAliasProps`
*
* @returns the AWS CloudFormation properties of an `AWS::KMS::Alias` resource.
*/
// @ts-ignore TS6133
function cfnAliasPropsToCloudFormation(properties: any): any {
if (!cdk.canInspect(properties)) { return properties; }
CfnAliasPropsValidator(properties).assertSuccess();
return {
AliasName: cdk.stringToCloudFormation(properties.aliasName),
TargetKeyId: cdk.stringToCloudFormation(properties.targetKeyId),
};
}
/**
* A CloudFormation `AWS::KMS::Alias`
*
* @cloudformationResource AWS::KMS::Alias
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-alias.html
*/
export class CfnAlias extends cdk.CfnResource {
/**
* The CloudFormation resource type name for this resource class.
*/
public static readonly cfnResourceTypeName = "AWS::KMS::Alias";
/**
* `AWS::KMS::Alias.AliasName`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-alias.html#cfn-kms-alias-aliasname
*/
public aliasName: string;
/**
* `AWS::KMS::Alias.TargetKeyId`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-alias.html#cfn-kms-alias-targetkeyid
*/
public targetKeyId: string;
/**
* Create a new `AWS::KMS::Alias`.
*
* @param scope - scope in which this resource is defined
* @param id - scoped id of the resource
* @param props - resource properties
*/
constructor(scope: cdk.Construct, id: string, props: CfnAliasProps) {
super(scope, id, { type: CfnAlias.cfnResourceTypeName, properties: props });
cdk.requireProperty(props, 'aliasName', this);
cdk.requireProperty(props, 'targetKeyId', this);
this.aliasName = props.aliasName;
this.targetKeyId = props.targetKeyId;
}
protected get cfnProperties(): { [key: string]: any } {
return {
aliasName: this.aliasName,
targetKeyId: this.targetKeyId,
};
}
protected renderProperties(props: {[key: string]: any}): { [key: string]: any } {
return cfnAliasPropsToCloudFormation(props);
}
}
/**
* Properties for defining a `AWS::KMS::Key`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html
*/
export interface CfnKeyProps {
/**
* `AWS::KMS::Key.KeyPolicy`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-keypolicy
*/
readonly keyPolicy: object | cdk.IResolvable;
/**
* `AWS::KMS::Key.Description`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-description
*/
readonly description?: string;
/**
* `AWS::KMS::Key.Enabled`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-enabled
*/
readonly enabled?: boolean | cdk.IResolvable;
/**
* `AWS::KMS::Key.EnableKeyRotation`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-enablekeyrotation
*/
readonly enableKeyRotation?: boolean | cdk.IResolvable;
/**
* `AWS::KMS::Key.KeyUsage`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-keyusage
*/
readonly keyUsage?: string;
/**
* `AWS::KMS::Key.PendingWindowInDays`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-pendingwindowindays
*/
readonly pendingWindowInDays?: number;
/**
* `AWS::KMS::Key.Tags`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-tags
*/
readonly tags?: cdk.CfnTag[];
}
/**
* Determine whether the given properties match those of a `CfnKeyProps`
*
* @param properties - the TypeScript properties of a `CfnKeyProps`
*
* @returns the result of the validation.
*/
function CfnKeyPropsValidator(properties: any): cdk.ValidationResult {
if (!cdk.canInspect(properties)) { return cdk.VALIDATION_SUCCESS; }
const errors = new cdk.ValidationResults();
errors.collect(cdk.propertyValidator('description', cdk.validateString)(properties.description));
errors.collect(cdk.propertyValidator('enableKeyRotation', cdk.validateBoolean)(properties.enableKeyRotation));
errors.collect(cdk.propertyValidator('enabled', cdk.validateBoolean)(properties.enabled));
errors.collect(cdk.propertyValidator('keyPolicy', cdk.requiredValidator)(properties.keyPolicy));
errors.collect(cdk.propertyValidator('keyPolicy', cdk.validateObject)(properties.keyPolicy));
errors.collect(cdk.propertyValidator('keyUsage', cdk.validateString)(properties.keyUsage));
errors.collect(cdk.propertyValidator('pendingWindowInDays', cdk.validateNumber)(properties.pendingWindowInDays));
errors.collect(cdk.propertyValidator('tags', cdk.listValidator(cdk.validateCfnTag))(properties.tags));
return errors.wrap('supplied properties not correct for "CfnKeyProps"');
}
/**
* Renders the AWS CloudFormation properties of an `AWS::KMS::Key` resource
*
* @param properties - the TypeScript properties of a `CfnKeyProps`
*
* @returns the AWS CloudFormation properties of an `AWS::KMS::Key` resource.
*/
// @ts-ignore TS6133
function cfnKeyPropsToCloudFormation(properties: any): any {
if (!cdk.canInspect(properties)) { return properties; }
CfnKeyPropsValidator(properties).assertSuccess();
return {
KeyPolicy: cdk.objectToCloudFormation(properties.keyPolicy),
Description: cdk.stringToCloudFormation(properties.description),
Enabled: cdk.booleanToCloudFormation(properties.enabled),
EnableKeyRotation: cdk.booleanToCloudFormation(properties.enableKeyRotation),
KeyUsage: cdk.stringToCloudFormation(properties.keyUsage),
PendingWindowInDays: cdk.numberToCloudFormation(properties.pendingWindowInDays),
Tags: cdk.listMapper(cdk.cfnTagToCloudFormation)(properties.tags),
};
}
/**
* A CloudFormation `AWS::KMS::Key`
*
* @cloudformationResource AWS::KMS::Key
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html
*/
export class CfnKey extends cdk.CfnResource {
/**
* The CloudFormation resource type name for this resource class.
*/
public static readonly cfnResourceTypeName = "AWS::KMS::Key";
/**
* @cloudformationAttribute Arn
*/
public readonly attrArn: string;
/**
* `AWS::KMS::Key.KeyPolicy`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-keypolicy
*/
public keyPolicy: object | cdk.IResolvable;
/**
* `AWS::KMS::Key.Description`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-description
*/
public description: string | undefined;
/**
* `AWS::KMS::Key.Enabled`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-enabled
*/
public enabled: boolean | cdk.IResolvable | undefined;
/**
* `AWS::KMS::Key.EnableKeyRotation`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-enablekeyrotation
*/
public enableKeyRotation: boolean | cdk.IResolvable | undefined;
/**
* `AWS::KMS::Key.KeyUsage`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-keyusage
*/
public keyUsage: string | undefined;
/**
* `AWS::KMS::Key.PendingWindowInDays`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-pendingwindowindays
*/
public pendingWindowInDays: number | undefined;
/**
* `AWS::KMS::Key.Tags`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-tags
*/
public readonly tags: cdk.TagManager;
/**
* Create a new `AWS::KMS::Key`.
*
* @param scope - scope in which this resource is defined
* @param id - scoped id of the resource
* @param props - resource properties
*/
constructor(scope: cdk.Construct, id: string, props: CfnKeyProps) {
super(scope, id, { type: CfnKey.cfnResourceTypeName, properties: props });
cdk.requireProperty(props, 'keyPolicy', this);
this.attrArn = cdk.Token.asString(this.getAtt('Arn'));
this.keyPolicy = props.keyPolicy;
this.description = props.description;
this.enabled = props.enabled;
this.enableKeyRotation = props.enableKeyRotation;
this.keyUsage = props.keyUsage;
this.pendingWindowInDays = props.pendingWindowInDays;
this.tags = new cdk.TagManager(cdk.TagType.Standard, "AWS::KMS::Key", props.tags);
}
protected get cfnProperties(): { [key: string]: any } {
return {
keyPolicy: this.keyPolicy,
description: this.description,
enabled: this.enabled,
enableKeyRotation: this.enableKeyRotation,
keyUsage: this.keyUsage,
pendingWindowInDays: this.pendingWindowInDays,
tags: this.tags.renderTags(),
};
}
protected renderProperties(props: {[key: string]: any}): { [key: string]: any } {
return cfnKeyPropsToCloudFormation(props);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment