constructor()

in 04-cloudformation/02-cdk/lib/demo-stack.ts [7:33]


  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    const myQueue = new sqs.Queue(this, 'MyQueue');
    
    myQueue.addToResourcePolicy(
      new iam.PolicyStatement({
        principals: [new iam.AnyPrincipal()],
        effect: iam.Effect.ALLOW,
        actions: ['sqs:SendMessage', 'sqs:ReceiveMessages'],
        resources: [myQueue.queueArn]
      }),
    )

    const role = new iam.Role(this, 'MyRole', {
      assumedBy: new CompositePrincipal(
        new AccountPrincipal("111222333444"),
        new AccountRootPrincipal()
      ) 
    });

    role.addToPolicy(new iam.PolicyStatement({
      effect: iam.Effect.ALLOW,
      actions: ['s3:ListBuckets'],
      resources: ['arn:aws:s3:::bucket-name']
    }));
  }