UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 13.6 kB
"use strict";var __runInitializers=exports&&exports.__runInitializers||function(thisArg,initializers,value){for(var useValue=arguments.length>2,i=0;i<initializers.length;i++)value=useValue?initializers[i].call(thisArg,value):initializers[i].call(thisArg);return useValue?value:void 0},__esDecorate=exports&&exports.__esDecorate||function(ctor,descriptorIn,decorators,contextIn,initializers,extraInitializers){function accept(f){if(f!==void 0&&typeof f!="function")throw new TypeError("Function expected");return f}for(var kind=contextIn.kind,key=kind==="getter"?"get":kind==="setter"?"set":"value",target=!descriptorIn&&ctor?contextIn.static?ctor:ctor.prototype:null,descriptor=descriptorIn||(target?Object.getOwnPropertyDescriptor(target,contextIn.name):{}),_,done=!1,i=decorators.length-1;i>=0;i--){var context={};for(var p in contextIn)context[p]=p==="access"?{}:contextIn[p];for(var p in contextIn.access)context.access[p]=contextIn.access[p];context.addInitializer=function(f){if(done)throw new TypeError("Cannot add initializers after decoration has completed");extraInitializers.push(accept(f||null))};var result=(0,decorators[i])(kind==="accessor"?{get:descriptor.get,set:descriptor.set}:descriptor[key],context);if(kind==="accessor"){if(result===void 0)continue;if(result===null||typeof result!="object")throw new TypeError("Object expected");(_=accept(result.get))&&(descriptor.get=_),(_=accept(result.set))&&(descriptor.set=_),(_=accept(result.init))&&initializers.unshift(_)}else(_=accept(result))&&(kind==="field"?initializers.unshift(_):descriptor[key]=_)}target&&Object.defineProperty(target,contextIn.name,descriptor),done=!0};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Activity=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var customer_managed_key_encryption_configuration_1=()=>{var tmp=require("./customer-managed-key-encryption-configuration");return customer_managed_key_encryption_configuration_1=()=>tmp,tmp},util_1=()=>{var tmp=require("./private/util");return util_1=()=>tmp,tmp},stepfunctions_canned_metrics_generated_1=()=>{var tmp=require("./stepfunctions-canned-metrics.generated");return stepfunctions_canned_metrics_generated_1=()=>tmp,tmp},stepfunctions_generated_1=()=>{var tmp=require("./stepfunctions.generated");return stepfunctions_generated_1=()=>tmp,tmp},cloudwatch=()=>{var tmp=require("../../aws-cloudwatch");return cloudwatch=()=>tmp,tmp},iam=()=>{var tmp=require("../../aws-iam");return iam=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp},metadata_resource_1=()=>{var tmp=require("../../core/lib/metadata-resource");return metadata_resource_1=()=>tmp,tmp},prop_injectable_1=()=>{var tmp=require("../../core/lib/prop-injectable");return prop_injectable_1=()=>tmp,tmp};let Activity=(()=>{let _classDecorators=[prop_injectable_1().propertyInjectable],_classDescriptor,_classExtraInitializers=[],_classThis,_classSuper=core_1().Resource,_instanceExtraInitializers=[],_grant_decorators,_metric_decorators,_metricRunTime_decorators,_metricScheduleTime_decorators,_metricTime_decorators,_metricScheduled_decorators,_metricTimedOut_decorators,_metricStarted_decorators,_metricSucceeded_decorators,_metricFailed_decorators,_metricHeartbeatTimedOut_decorators;var Activity2=class extends _classSuper{static{_classThis=this}static{const _metadata=typeof Symbol=="function"&&Symbol.metadata?Object.create(_classSuper[Symbol.metadata]??null):void 0;_grant_decorators=[(0,metadata_resource_1().MethodMetadata)()],_metric_decorators=[(0,metadata_resource_1().MethodMetadata)()],_metricRunTime_decorators=[(0,metadata_resource_1().MethodMetadata)()],_metricScheduleTime_decorators=[(0,metadata_resource_1().MethodMetadata)()],_metricTime_decorators=[(0,metadata_resource_1().MethodMetadata)()],_metricScheduled_decorators=[(0,metadata_resource_1().MethodMetadata)()],_metricTimedOut_decorators=[(0,metadata_resource_1().MethodMetadata)()],_metricStarted_decorators=[(0,metadata_resource_1().MethodMetadata)()],_metricSucceeded_decorators=[(0,metadata_resource_1().MethodMetadata)()],_metricFailed_decorators=[(0,metadata_resource_1().MethodMetadata)()],_metricHeartbeatTimedOut_decorators=[(0,metadata_resource_1().MethodMetadata)()],__esDecorate(this,null,_grant_decorators,{kind:"method",name:"grant",static:!1,private:!1,access:{has:obj=>"grant"in obj,get:obj=>obj.grant},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,_metric_decorators,{kind:"method",name:"metric",static:!1,private:!1,access:{has:obj=>"metric"in obj,get:obj=>obj.metric},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,_metricRunTime_decorators,{kind:"method",name:"metricRunTime",static:!1,private:!1,access:{has:obj=>"metricRunTime"in obj,get:obj=>obj.metricRunTime},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,_metricScheduleTime_decorators,{kind:"method",name:"metricScheduleTime",static:!1,private:!1,access:{has:obj=>"metricScheduleTime"in obj,get:obj=>obj.metricScheduleTime},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,_metricTime_decorators,{kind:"method",name:"metricTime",static:!1,private:!1,access:{has:obj=>"metricTime"in obj,get:obj=>obj.metricTime},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,_metricScheduled_decorators,{kind:"method",name:"metricScheduled",static:!1,private:!1,access:{has:obj=>"metricScheduled"in obj,get:obj=>obj.metricScheduled},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,_metricTimedOut_decorators,{kind:"method",name:"metricTimedOut",static:!1,private:!1,access:{has:obj=>"metricTimedOut"in obj,get:obj=>obj.metricTimedOut},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,_metricStarted_decorators,{kind:"method",name:"metricStarted",static:!1,private:!1,access:{has:obj=>"metricStarted"in obj,get:obj=>obj.metricStarted},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,_metricSucceeded_decorators,{kind:"method",name:"metricSucceeded",static:!1,private:!1,access:{has:obj=>"metricSucceeded"in obj,get:obj=>obj.metricSucceeded},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,_metricFailed_decorators,{kind:"method",name:"metricFailed",static:!1,private:!1,access:{has:obj=>"metricFailed"in obj,get:obj=>obj.metricFailed},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,_metricHeartbeatTimedOut_decorators,{kind:"method",name:"metricHeartbeatTimedOut",static:!1,private:!1,access:{has:obj=>"metricHeartbeatTimedOut"in obj,get:obj=>obj.metricHeartbeatTimedOut},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(null,_classDescriptor={value:_classThis},_classDecorators,{kind:"class",name:_classThis.name,metadata:_metadata},null,_classExtraInitializers),Activity2=_classThis=_classDescriptor.value,_metadata&&Object.defineProperty(_classThis,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:_metadata})}static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_stepfunctions.Activity",version:"2.233.0"};static PROPERTY_INJECTION_ID="aws-cdk-lib.aws-stepfunctions.Activity";static fromActivityArn(scope,id,activityArn){class Imported extends core_1().Resource{get activityArn(){return activityArn}get activityName(){return core_1().Stack.of(this).splitArn(activityArn,core_1().ArnFormat.COLON_RESOURCE_NAME).resourceName||""}}return new Imported(scope,id)}static fromActivityName(scope,id,activityName){return Activity2.fromActivityArn(scope,id,core_1().Stack.of(scope).formatArn({service:"states",resource:"activity",resourceName:activityName,arnFormat:core_1().ArnFormat.COLON_RESOURCE_NAME}))}activityArn=__runInitializers(this,_instanceExtraInitializers);activityName;encryptionConfiguration;constructor(scope,id,props={}){super(scope,id,{physicalName:props.activityName||core_1().Lazy.string({produce:()=>this.generateName()})});try{jsiiDeprecationWarnings().aws_cdk_lib_aws_stepfunctions_ActivityProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,Activity2),error}(0,metadata_resource_1().addConstructMetadata)(this,props),this.encryptionConfiguration=props.encryptionConfiguration,props.encryptionConfiguration instanceof customer_managed_key_encryption_configuration_1().CustomerManagedEncryptionConfiguration&&props.encryptionConfiguration.kmsKey.addToResourcePolicy(new(iam()).PolicyStatement({resources:["*"],actions:["kms:Decrypt","kms:GenerateDataKey"],principals:[new(iam()).ServicePrincipal("states.amazonaws.com")],conditions:{StringEquals:{"kms:EncryptionContext:aws:states:activityArn":core_1().Stack.of(this).formatArn({service:"states",resource:"activity",sep:":",resourceName:this.physicalName})}}}));const resource=new(stepfunctions_generated_1()).CfnActivity(this,"Resource",{name:this.physicalName,encryptionConfiguration:(0,util_1().buildEncryptionConfiguration)(props.encryptionConfiguration)});this.activityArn=this.getResourceArnAttribute(resource.ref,{service:"states",resource:"activity",resourceName:this.physicalName,arnFormat:core_1().ArnFormat.COLON_RESOURCE_NAME}),this.activityName=this.getResourceNameAttribute(resource.attrName)}grant(identity,...actions){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_iam_IGrantable(identity)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.grant),error}return iam().Grant.addToPrincipal({grantee:identity,actions,resourceArns:[this.activityArn]})}metric(metricName,props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metric),error}return new(cloudwatch()).Metric({namespace:"AWS/States",metricName,dimensions:{ActivityArn:this.activityArn},statistic:"sum",...props}).attachTo(this)}metricRunTime(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricRunTime),error}return this.cannedMetric(stepfunctions_canned_metrics_generated_1().StatesMetrics.activityRunTimeAverage,props)}metricScheduleTime(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricScheduleTime),error}return this.cannedMetric(stepfunctions_canned_metrics_generated_1().StatesMetrics.activityScheduleTimeAverage,props)}metricTime(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricTime),error}return this.cannedMetric(stepfunctions_canned_metrics_generated_1().StatesMetrics.activityTimeAverage,props)}metricScheduled(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricScheduled),error}return this.cannedMetric(stepfunctions_canned_metrics_generated_1().StatesMetrics.activitiesScheduledSum,props)}metricTimedOut(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricTimedOut),error}return this.cannedMetric(stepfunctions_canned_metrics_generated_1().StatesMetrics.activitiesTimedOutSum,props)}metricStarted(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricStarted),error}return this.cannedMetric(stepfunctions_canned_metrics_generated_1().StatesMetrics.activitiesStartedSum,props)}metricSucceeded(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricSucceeded),error}return this.cannedMetric(stepfunctions_canned_metrics_generated_1().StatesMetrics.activitiesSucceededSum,props)}metricFailed(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricFailed),error}return this.cannedMetric(stepfunctions_canned_metrics_generated_1().StatesMetrics.activitiesFailedSum,props)}metricHeartbeatTimedOut(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricHeartbeatTimedOut),error}return this.cannedMetric(stepfunctions_canned_metrics_generated_1().StatesMetrics.activitiesHeartbeatTimedOutSum,props)}generateName(){const name=core_1().Names.uniqueId(this);return name.length>80?name.substring(0,40)+name.substring(name.length-40):name}cannedMetric(fn,props){return new(cloudwatch()).Metric({...fn({ActivityArn:this.activityArn}),...props}).attachTo(this)}static{__runInitializers(_classThis,_classExtraInitializers)}};return Activity2=_classThis})();exports.Activity=Activity;