aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
2 lines (1 loc) • 7.14 kB
JavaScript
;var __createBinding=exports&&exports.__createBinding||(Object.create?(function(o,m,k,k2){k2===void 0&&(k2=k);var desc=Object.getOwnPropertyDescriptor(m,k);(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable))&&(desc={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){k2===void 0&&(k2=k),o[k2]=m[k]})),__setModuleDefault=exports&&exports.__setModuleDefault||(Object.create?(function(o,v){Object.defineProperty(o,"default",{enumerable:!0,value:v})}):function(o,v){o.default=v}),__importStar=exports&&exports.__importStar||(function(){var ownKeys=function(o){return ownKeys=Object.getOwnPropertyNames||function(o2){var ar=[];for(var k in o2)Object.prototype.hasOwnProperty.call(o2,k)&&(ar[ar.length]=k);return ar},ownKeys(o)};return function(mod){if(mod&&mod.__esModule)return mod;var result={};if(mod!=null)for(var k=ownKeys(mod),i=0;i<k.length;i++)k[i]!=="default"&&__createBinding(result,mod,k[i]);return __setModuleDefault(result,mod),result}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.Ec2DeployAction=exports.Ec2MaxInstances=exports.Ec2DeploySpecifications=exports.Ec2InstanceType=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var codepipeline=()=>{var tmp=__importStar(require("../../../aws-codepipeline"));return codepipeline=()=>tmp,tmp},iam=()=>{var tmp=__importStar(require("../../../aws-iam"));return iam=()=>tmp,tmp},core_1=()=>{var tmp=require("../../../core");return core_1=()=>tmp,tmp},literal_string_1=()=>{var tmp=require("../../../core/lib/private/literal-string");return literal_string_1=()=>tmp,tmp},action_1=()=>{var tmp=require("../action");return action_1=()=>tmp,tmp},common_1=()=>{var tmp=require("../common");return common_1=()=>tmp,tmp},Ec2InstanceType;(function(Ec2InstanceType2){Ec2InstanceType2.EC2="EC2",Ec2InstanceType2.SSM_MANAGED_NODE="SSM_MANAGED_NODE"})(Ec2InstanceType||(exports.Ec2InstanceType=Ec2InstanceType={}));class Ec2DeploySpecifications{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_codepipeline_actions.Ec2DeploySpecifications",version:"2.260.0"};static inline(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_codepipeline_actions_Ec2DeploySpecificationsInlineProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.inline),error}return new Ec2DeploySpecificationsInline(props)}}exports.Ec2DeploySpecifications=Ec2DeploySpecifications;class Ec2DeploySpecificationsInline extends Ec2DeploySpecifications{props;constructor(props){super(),this.props=props}bind(scope){if(!core_1().Token.isUnresolved(this.props.targetDirectory)&&!this.props.targetDirectory.startsWith("/"))throw new(core_1()).ValidationError((0,literal_string_1().lit)`TargetDirectoryAbsolutePath`,"The targetDirectory must be an absolute path.",scope);return{TargetDirectory:this.props.targetDirectory,PreScript:this.props.preScript,PostScript:this.props.postScript}}}class Ec2MaxInstances{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_codepipeline_actions.Ec2MaxInstances",version:"2.260.0"};static targets(targets){if(!core_1().Token.isUnresolved(targets)&&!(targets>=1&&Number.isInteger(targets)))throw new(core_1()).UnscopedValidationError((0,literal_string_1().lit)`MustBeTargetsPositiveInteger`,`targets must be a positive integer. got ${targets}`);return{value:core_1().Tokenization.stringifyNumber(targets)}}static percentage(percentage){if(!core_1().Token.isUnresolved(percentage)&&!(percentage>=1&&percentage<=100&&Number.isInteger(percentage)))throw new(core_1()).UnscopedValidationError((0,literal_string_1().lit)`MustBePercentagePositiveInteger`,`percentage must be a positive integer between 1 and 100. got ${percentage}`);return{value:`${core_1().Tokenization.stringifyNumber(percentage)}%`}}}exports.Ec2MaxInstances=Ec2MaxInstances;class Ec2DeployAction extends action_1().Action{props;static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_codepipeline_actions.Ec2DeployAction",version:"2.260.0"};constructor(props){super({...props,category:codepipeline().ActionCategory.DEPLOY,provider:"EC2",artifactBounds:(0,common_1().deployArtifactBounds)(),inputs:[props.input]}),this.props=props;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_codepipeline_actions_Ec2DeployActionProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,Ec2DeployAction),error}}bound(scope,stage,options){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_codepipeline_IStage(stage),jsiiDeprecationWarnings().aws_cdk_lib_aws_codepipeline_ActionBindOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bound),error}if(core_1().Token.isUnresolved(this.props.instanceTagKey))throw new(core_1()).ValidationError((0,literal_string_1().lit)`InstanceTagKeyNonEmpty`,"The instanceTagKey must be a non-empty concrete value.",scope);return options.role.addToPrincipalPolicy(new(iam()).PolicyStatement({actions:["ec2:DescribeInstances","elasticloadbalancing:DescribeTargetGroupAttributes","elasticloadbalancing:DescribeTargetGroups","elasticloadbalancing:DescribeTargetHealth","ssm:CancelCommand","ssm:DescribeInstanceInformation","ssm:ListCommandInvocations"],resources:["*"]})),options.role.addToPrincipalPolicy(new(iam()).PolicyStatement({actions:["logs:CreateLogGroup","logs:CreateLogStream","logs:PutLogEvents"],resources:[core_1().Stack.of(scope).formatArn({service:"logs",resource:"log-group",resourceName:`/aws/codepipeline/${stage.pipeline.pipelineName}:*`,arnFormat:core_1().ArnFormat.COLON_RESOURCE_NAME})]})),options.role.addToPrincipalPolicy(new(iam()).PolicyStatement({actions:["ssm:SendCommand"],resources:[core_1().Stack.of(scope).formatArn({service:"ec2",resource:"instance",resourceName:"*"})],conditions:this.props.instanceTagValue?{StringEquals:{[`aws:ResourceTag/${this.props.instanceTagKey}`]:this.props.instanceTagValue}}:{Null:{[`aws:ResourceTag/${this.props.instanceTagKey}`]:"false"}}})),options.role.addToPrincipalPolicy(new(iam()).PolicyStatement({actions:["ssm:SendCommand"],resources:[core_1().Stack.of(scope).formatArn({service:"ssm",account:"",resource:"document/AWS-RunPowerShellScript"}),core_1().Stack.of(scope).formatArn({service:"ssm",account:"",resource:"document/AWS-RunShellScript"})]})),this.props.targetGroups?.length&&options.role.addToPrincipalPolicy(new(iam()).PolicyStatement({actions:["elasticloadbalancing:DeregisterTargets","elasticloadbalancing:RegisterTargets"],resources:this.props.targetGroups.map(tg=>tg.targetGroupArn)})),{configuration:{InstanceTagKey:this.props.instanceTagKey,InstanceTagValue:this.props.instanceTagValue,InstanceType:this.props.instanceType,MaxBatch:this.props.maxBatch?.value,MaxError:this.props.maxError?.value,TargetGroupNameList:this.props.targetGroups?.length?this.props.targetGroups.map(tg=>tg.targetGroupName).join(","):void 0,...this.props.deploySpecifications.bind(scope)}}}}exports.Ec2DeployAction=Ec2DeployAction;