aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
2 lines (1 loc) • 2.02 kB
JavaScript
Object.defineProperty(exports,"__esModule",{value:!0}),exports.ReplicaProvider=void 0;var iam=()=>{var tmp=require("../../aws-iam");return iam=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp},replica_provider_generated_1=()=>{var tmp=require("../../custom-resource-handlers/dist/aws-dynamodb/replica-provider.generated");return replica_provider_generated_1=()=>tmp,tmp},cr=()=>{var tmp=require("../../custom-resources");return cr=()=>tmp,tmp};class ReplicaProvider extends core_1().NestedStack{static getOrCreate(scope,props){const stack=core_1().Stack.of(scope),uid="@aws-cdk/aws-dynamodb.ReplicaProvider";return stack.node.tryFindChild(uid)??new ReplicaProvider(stack,uid,props)}constructor(scope,id,props){super(scope,id),this.onEventHandler=new(replica_provider_generated_1()).ReplicaOnEventFunction(this,"OnEventHandler",{timeout:core_1().Duration.minutes(5)}),this.isCompleteHandler=new(replica_provider_generated_1()).ReplicaIsCompleteFunction(this,"IsCompleteHandler",{timeout:core_1().Duration.seconds(30)}),this.onEventHandler.addToRolePolicy(new(iam()).PolicyStatement({actions:["iam:CreateServiceLinkedRole"],resources:[core_1().Stack.of(this).formatArn({service:"iam",region:"",resource:"role",resourceName:"aws-service-role/replication.dynamodb.amazonaws.com/AWSServiceRoleForDynamoDBReplication"})]})),this.onEventHandler.addToRolePolicy(new(iam()).PolicyStatement({actions:["dynamodb:DescribeLimits"],resources:["*"]}));let resources=[];props.regions.forEach(region=>{resources.push(`arn:${core_1().Aws.PARTITION}:dynamodb:${region}:${this.account}:table/${props.tableName}`)}),this.onEventHandler.addToRolePolicy(new(iam()).PolicyStatement({actions:["dynamodb:DeleteTable","dynamodb:DeleteTableReplica"],resources})),this.provider=new(cr()).Provider(this,"Provider",{onEventHandler:this.onEventHandler,isCompleteHandler:this.isCompleteHandler,queryInterval:core_1().Duration.seconds(10),totalTimeout:props.timeout})}}exports.ReplicaProvider=ReplicaProvider;
;