aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
2 lines (1 loc) • 5.81 kB
JavaScript
;var _a,_b,_c;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=require("../../../aws-codepipeline");return codepipeline=()=>tmp,tmp},iam=()=>{var tmp=require("../../../aws-iam");return iam=()=>tmp,tmp},core_1=()=>{var tmp=require("../../../core");return core_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 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,_a=JSII_RTTI_SYMBOL_1,Ec2DeploySpecifications[_a]={fqn:"aws-cdk-lib.aws_codepipeline_actions.Ec2DeploySpecifications",version:"2.210.0"};class Ec2DeploySpecificationsInline extends Ec2DeploySpecifications{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("The targetDirectory must be an absolute path.",scope);return{TargetDirectory:this.props.targetDirectory,PreScript:this.props.preScript,PostScript:this.props.postScript}}}class Ec2MaxInstances{static targets(targets){if(!core_1().Token.isUnresolved(targets)&&!(targets>=1&&Number.isInteger(targets)))throw new(core_1()).UnscopedValidationError(`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(`percentage must be a positive integer between 1 and 100. got ${percentage}`);return{value:`${core_1().Tokenization.stringifyNumber(percentage)}%`}}}exports.Ec2MaxInstances=Ec2MaxInstances,_b=JSII_RTTI_SYMBOL_1,Ec2MaxInstances[_b]={fqn:"aws-cdk-lib.aws_codepipeline_actions.Ec2MaxInstances",version:"2.210.0"};class Ec2DeployAction extends action_1().Action{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("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,_c=JSII_RTTI_SYMBOL_1,Ec2DeployAction[_c]={fqn:"aws-cdk-lib.aws_codepipeline_actions.Ec2DeployAction",version:"2.210.0"};