aws-samples / aws-cdk-examples

Example projects using the AWS CDK
Apache License 2.0
5.07k stars 2.13k forks source link

java cdk example not working #739

Open nagkumar opened 1 year ago

nagkumar commented 1 year ago

Describe the bug

Example https://github.com/aws-samples/aws-cdk-examples/tree/master/java/hello-world not working, it gives error

Expected Behavior

Example should work with out any errors

Current Behavior

G:\DWork\osource\cloudc\devops\iac\aws\java\hello-world> cdk deploy [INFO] Scanning for projects... [INFO] [INFO] --------------------< com.amazonaws.cdk:hello-cdk >--------------------- [INFO] Building hello-cdk 1.0.0 [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- exec-maven-plugin:3.1.0:java (default-cli) @ hello-cdk --- [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 29.424 s [INFO] Finished at: 2022-09-22T19:38:29+05:30 [INFO] ------------------------------------------------------------------------

✨ Synthesis time: 31.04s

This deployment will make potentially sensitive changes according to your current security approval level (--require-approval broadening). Please confirm you intend to make the following modifications:

IAM Statement Changes ┌───┬───────────────┬────────┬───────────────┬───────────────┬────────────────┐ │ │ Resource │ Effect │ Action │ Principal │ Condition │ ├───┼───────────────┼────────┼───────────────┼───────────────┼────────────────┤ │ + │ ${MyAutoScali │ Allow │ sts:AssumeRol │ Service:ec2.$ │ │ │ │ ngGroup/Compu │ │ e │ {AWS::URLSuff │ │ │ │ te/InstanceRo │ │ │ ix} │ │ │ │ le.Arn} │ │ │ │ │ ├───┼───────────────┼────────┼───────────────┼───────────────┼────────────────┤ │ + │ ${MySinkQueue │ Allow │ sqs:SendMessa │ Service:sns.a │ "ArnEquals": { │ │ │ /Resource.Arn │ │ ge │ mazonaws.com │ "aws:SourceA │ │ │ } │ │ │ │ rn": "${Topic1 │ │ │ │ │ │ │ }" │ │ │ │ │ │ │ } │ │ + │ ${MySinkQueue │ Allow │ sqs:SendMessa │ Service:sns.a │ "ArnEquals": { │ │ │ /Resource.Arn │ │ ge │ mazonaws.com │ "aws:SourceA │ │ │ } │ │ │ │ rn": "${Topic2 │ │ │ │ │ │ │ }" │ │ │ │ │ │ │ } │ │ + │ ${MySinkQueue │ Allow │ sqs:SendMessa │ Service:sns.a │ "ArnEquals": { │ │ │ /Resource.Arn │ │ ge │ mazonaws.com │ "aws:SourceA │ │ │ } │ │ │ │ rn": "${Topic3 │ │ │ │ │ │ │ }" │ │ │ │ │ │ │ } │ │ + │ ${MySinkQueue │ Allow │ sqs:SendMessa │ Service:sns.a │ "ArnEquals": { │ │ │ /Resource.Arn │ │ ge │ mazonaws.com │ "aws:SourceA │ │ │ } │ │ │ │ rn": "${Topic4 │ │ │ │ │ │ │ }" │ │ │ │ │ │ │ } │ │ + │ ${MySinkQueue │ Allow │ sqs:SendMessa │ Service:sns.a │ "ArnEquals": { │ │ │ /Resource.Arn │ │ ge │ mazonaws.com │ "aws:SourceA │ │ │ } │ │ │ │ rn": "${Topic5 │ │ │ │ │ │ │ }" │ │ │ │ │ │ │ } │ └───┴───────────────┴────────┴───────────────┴───────────────┴────────────────┘ Security Group Changes ┌───┬──────────────────────────┬─────┬────────────┬───────────────────────────┐ │ │ Group │ Dir │ Protocol │ Peer │ ├───┼──────────────────────────┼─────┼────────────┼───────────────────────────┤ │ + │ ${MyAutoScalingGroup/Com │ Out │ Everything │ Everyone (IPv4) │ │ │ pute/InstanceSecurityGro │ │ │ │ │ │ up.GroupId} │ │ │ │ └───┴──────────────────────────┴─────┴────────────┴───────────────────────────┘ (NOTE: There may be security-related changes not in this list. See https://github.com/aws/aws-cdk/issues/1299)

Do you wish to deploy these changes (y/n)? y hello-cdk: deploying... hello-cdk: creating CloudFormation changeset... hello-cdk | 0/42 | 7:39:13 pm | REVIEW_IN_PROGRESS | AWS::CloudFormation::Stack | hello-cdk User Initiated hello-cdk | 0/42 | 7:39:20 pm | CREATE_IN_PROGRESS | AWS::CloudFormation::Stack | hello-cdk User Initiated hello-cdk | 0/42 | 7:39:24 pm | CREATE_IN_PROGRESS | AWS::EC2::InternetGateway | VPC/IGW (VPCIGWB7E252D3) hello-cdk | 0/42 | 7:39:24 pm | CREATE_IN_PROGRESS | AWS::EC2::EIP | VPC/PublicSubnet2/EIP (VPCPublicSubnet2EIP4947BC00) hello-cdk | 0/42 | 7:39:24 pm | CREATE_IN_PROGRESS | AWS::SNS::Topic | Topic2 (Topic269377B75) hello-cdk | 0/42 | 7:39:24 pm | CREATE_IN_PROGRESS | AWS::IAM::Role | MyAutoScalingGroup/Compute/InstanceRole (MyAutoScalingGroupComputeInstanceRole1B510108) hello-cdk | 0/42 | 7:39:24 pm | CREATE_IN_PROGRESS | AWS::SNS::Topic | Topic1 (Topic198E71B3E) hello-cdk | 0/42 | 7:39:24 pm | CREATE_IN_PROGRESS | AWS::EC2::VPC | VPC (VPCB9E5F0B4) hello-cdk | 0/42 | 7:39:24 pm | CREATE_IN_PROGRESS | AWS::CDK::Metadata | CDKMetadata/Default (CDKMetadata) hello-cdk | 0/42 | 7:39:24 pm | CREATE_IN_PROGRESS | AWS::SNS::Topic | Topic4 (Topic4F5C0CEE2) hello-cdk | 0/42 | 7:39:24 pm | CREATE_IN_PROGRESS | AWS::SQS::Queue | MySinkQueue/Resource (MySinkQueueEFCD79C2) hello-cdk | 0/42 | 7:39:24 pm | CREATE_IN_PROGRESS | AWS::SNS::Topic | Topic5 (Topic5A03540AE) hello-cdk | 0/42 | 7:39:24 pm | CREATE_IN_PROGRESS | AWS::SNS::Topic | Topic3 (Topic3DEAE47A7) hello-cdk | 0/42 | 7:39:24 pm | CREATE_IN_PROGRESS | AWS::EC2::EIP | VPC/PublicSubnet1/EIP (VPCPublicSubnet1EIP6AD938E8) hello-cdk | 0/42 | 7:39:24 pm | CREATE_IN_PROGRESS | AWS::IAM::Role | MyAutoScalingGroup/Compute/InstanceRole (MyAutoScalingGroupComputeInstanceRole1B510108) Resource creation Initiated hello-cdk | 0/42 | 7:39:25 pm | CREATE_IN_PROGRESS | AWS::EC2::InternetGateway | VPC/IGW (VPCIGWB7E252D3) Resource creation Initiated hello-cdk | 0/42 | 7:39:25 pm | CREATE_IN_PROGRESS | AWS::SNS::Topic | Topic4 (Topic4F5C0CEE2) Resource creation Initiated hello-cdk | 0/42 | 7:39:25 pm | CREATE_IN_PROGRESS | AWS::CDK::Metadata | CDKMetadata/Default (CDKMetadata) Resource creation Initiated hello-cdk | 0/42 | 7:39:25 pm | CREATE_IN_PROGRESS | AWS::SNS::Topic | Topic2 (Topic269377B75) Resource creation Initiated hello-cdk | 0/42 | 7:39:25 pm | CREATE_IN_PROGRESS | AWS::SQS::Queue | MySinkQueue/Resource (MySinkQueueEFCD79C2) Resource creation Initiated hello-cdk | 1/42 | 7:39:25 pm | CREATE_COMPLETE | AWS::CDK::Metadata | CDKMetadata/Default (CDKMetadata) hello-cdk | 2/42 | 7:39:25 pm | CREATE_COMPLETE | AWS::SNS::Topic | Topic4 (Topic4F5C0CEE2) hello-cdk | 2/42 | 7:39:25 pm | CREATE_IN_PROGRESS | AWS::SNS::Topic | Topic3 (Topic3DEAE47A7) Resource creation Initiated hello-cdk | 3/42 | 7:39:26 pm | CREATE_COMPLETE | AWS::SNS::Topic | Topic2 (Topic269377B75) hello-cdk | 3/42 | 7:39:26 pm | CREATE_IN_PROGRESS | AWS::EC2::VPC | VPC (VPCB9E5F0B4) Resource creation Initiated hello-cdk | 3/42 | 7:39:26 pm | CREATE_IN_PROGRESS | AWS::SNS::Topic | Topic5 (Topic5A03540AE) Resource creation Initiated hello-cdk | 4/42 | 7:39:26 pm | CREATE_COMPLETE | AWS::SNS::Topic | Topic3 (Topic3DEAE47A7) hello-cdk | 4/42 | 7:39:26 pm | CREATE_IN_PROGRESS | AWS::SNS::Topic | Topic1 (Topic198E71B3E) Resource creation Initiated hello-cdk | 5/42 | 7:39:26 pm | CREATE_COMPLETE | AWS::SNS::Topic | Topic5 (Topic5A03540AE) hello-cdk | 6/42 | 7:39:26 pm | CREATE_COMPLETE | AWS::SNS::Topic | Topic1 (Topic198E71B3E) hello-cdk | 7/42 | 7:39:37 pm | CREATE_COMPLETE | AWS::EC2::VPC | VPC (VPCB9E5F0B4) hello-cdk | 7/42 | 7:39:39 pm | CREATE_IN_PROGRESS | AWS::EC2::RouteTable | VPC/PrivateSubnet1/RouteTable (VPCPrivateSubnet1RouteTableBE8A6027) hello-cdk | 7/42 | 7:39:39 pm | CREATE_IN_PROGRESS | AWS::EC2::RouteTable | VPC/PublicSubnet2/RouteTable (VPCPublicSubnet2RouteTable6F1A15F1) hello-cdk | 7/42 | 7:39:39 pm | CREATE_FAILED | AWS::EC2::Subnet | VPC/PublicSubnet2/Subnet (VPCPublicSubnet2Subnet74179F39) Template error: Fn::Select cannot select nonexistent value at index 1 hello-cdk | 7/42 | 7:39:39 pm | CREATE_FAILED | AWS::EC2::Subnet | VPC/PrivateSubnet2/Subnet (VPCPrivateSubnet2SubnetCFCDAA7A) Template error: Fn::Select cannot select nonexistent value at index 1 hello-cdk | 7/42 | 7:39:39 pm | CREATE_IN_PROGRESS | AWS::EC2::SecurityGroup | MyAutoScalingGroup/Compute/InstanceSecurityGroup (MyAutoScalingGroupComputeInstanceSecurityGroup2222F5E5) hello-cdk | 7/42 | 7:39:39 pm | CREATE_IN_PROGRESS | AWS::EC2::EIP | VPC/PublicSubnet2/EIP (VPCPublicSubnet2EIP4947BC00) Resource creation Initiated hello-cdk | 7/42 | 7:39:39 pm | CREATE_IN_PROGRESS | AWS::EC2::RouteTable | VPC/PublicSubnet1/RouteTable (VPCPublicSubnet1RouteTableFEE4B781) hello-cdk | 7/42 | 7:39:39 pm | CREATE_IN_PROGRESS | AWS::EC2::RouteTable | VPC/PrivateSubnet2/RouteTable (VPCPrivateSubnet2RouteTable0A19E10E) hello-cdk | 7/42 | 7:39:39 pm | CREATE_FAILED | AWS::IAM::Role | MyAutoScalingGroup/Compute/InstanceRole (MyAutoScalingGroupComputeInstanceRole1B510108) Resource creation cancelled hello-cdk | 7/42 | 7:39:39 pm | CREATE_FAILED | AWS::EC2::EIP | VPC/PublicSubnet1/EIP (VPCPublicSubnet1EIP6AD938E8) Resource creation cancelled hello-cdk | 7/42 | 7:39:39 pm | CREATE_FAILED | AWS::EC2::RouteTable | VPC/PublicSubnet1/RouteTable (VPCPublicSubnet1RouteTableFEE4B781) Resource creation cancelled hello-cdk | 7/42 | 7:39:39 pm | CREATE_FAILED | AWS::EC2::EIP | VPC/PublicSubnet2/EIP (VPCPublicSubnet2EIP4947BC00) Resource creation cancelled hello-cdk | 7/42 | 7:39:39 pm | CREATE_FAILED | AWS::EC2::RouteTable | VPC/PrivateSubnet2/RouteTable (VPCPrivateSubnet2RouteTable0A19E10E) Resource creation cancelled hello-cdk | 7/42 | 7:39:39 pm | CREATE_FAILED | AWS::SQS::Queue | MySinkQueue/Resource (MySinkQueueEFCD79C2) Resource creation cancelled hello-cdk | 7/42 | 7:39:39 pm | CREATE_FAILED | AWS::EC2::InternetGateway | VPC/IGW (VPCIGWB7E252D3) Resource creation cancelled hello-cdk | 7/42 | 7:39:39 pm | CREATE_FAILED | AWS::EC2::RouteTable | VPC/PublicSubnet2/RouteTable (VPCPublicSubnet2RouteTable6F1A15F1) Resource creation cancelled hello-cdk | 7/42 | 7:39:39 pm | CREATE_FAILED | AWS::EC2::RouteTable | VPC/PrivateSubnet1/RouteTable (VPCPrivateSubnet1RouteTableBE8A6027) Resource creation cancelled hello-cdk | 7/42 | 7:39:44 pm | CREATE_FAILED | AWS::EC2::SecurityGroup | MyAutoScalingGroup/Compute/InstanceSecurityGroup (MyAutoScalingGroupComputeInstanceSecurityGroup2222F5E5) Resource creation cancelled hello-cdk | 7/42 | 7:39:44 pm | ROLLBACK_IN_PROGRESS | AWS::CloudFormation::Stack | hello-cdk The following resource(s) failed to create: [VPCPrivateSubnet2SubnetCFCDAA7A, VPCPublicSubnet1RouteTableFEE4B781, VPCIGWB7E252D3, MyAutoScalingGroupComputeInstanceSecurityGroup2222F5E5, VPCPublicSubnet1EIP6AD938E8, VPCPublicSubnet2Subnet74179F39, VPCPrivateSubnet1RouteTableBE8A6027, VPCPrivateSubnet2RouteTable0A19E10E, VPCPublicSubnet2RouteTable6F1A15F1, VPCPublicSubnet2EIP4947BC00, MySinkQueueEFCD79C2, MyAutoScalingGroupComputeInstanceRole1B510108]. Rollback requested by user. hello-cdk | 8/42 | 7:39:50 pm | DELETE_COMPLETE | AWS::EC2::Subnet | VPC/PrivateSubnet2/Subnet (VPCPrivateSubnet2SubnetCFCDAA7A) hello-cdk | 8/42 | 7:39:50 pm | DELETE_IN_PROGRESS | AWS::SNS::Topic | Topic2 (Topic269377B75) hello-cdk | 8/42 | 7:39:50 pm | DELETE_IN_PROGRESS | AWS::EC2::InternetGateway | VPC/IGW (VPCIGWB7E252D3) hello-cdk | 8/42 | 7:39:50 pm | DELETE_IN_PROGRESS | AWS::CDK::Metadata | CDKMetadata/Default (CDKMetadata) hello-cdk | 8/42 | 7:39:50 pm | DELETE_IN_PROGRESS | AWS::IAM::Role | MyAutoScalingGroup/Compute/InstanceRole (MyAutoScalingGroupComputeInstanceRole1B510108) hello-cdk | 8/42 | 7:39:50 pm | DELETE_IN_PROGRESS | AWS::SQS::Queue | MySinkQueue/Resource (MySinkQueueEFCD79C2) hello-cdk | 8/42 | 7:39:50 pm | DELETE_IN_PROGRESS | AWS::EC2::EIP | VPC/PublicSubnet2/EIP (VPCPublicSubnet2EIP4947BC00) hello-cdk | 8/42 | 7:39:50 pm | DELETE_IN_PROGRESS | AWS::SNS::Topic | Topic4 (Topic4F5C0CEE2) hello-cdk | 8/42 | 7:39:50 pm | DELETE_IN_PROGRESS | AWS::SNS::Topic | Topic5 (Topic5A03540AE) hello-cdk | 8/42 | 7:39:50 pm | DELETE_IN_PROGRESS | AWS::EC2::EIP | VPC/PublicSubnet1/EIP (VPCPublicSubnet1EIP6AD938E8) hello-cdk | 8/42 | 7:39:50 pm | DELETE_IN_PROGRESS | AWS::SNS::Topic | Topic1 (Topic198E71B3E) hello-cdk | 8/42 | 7:39:50 pm | DELETE_IN_PROGRESS | AWS::EC2::SecurityGroup | MyAutoScalingGroup/Compute/InstanceSecurityGroup (MyAutoScalingGroupComputeInstanceSecurityGroup2222F5E5) hello-cdk | 9/42 | 7:39:50 pm | DELETE_COMPLETE | AWS::EC2::Subnet | VPC/PublicSubnet2/Subnet (VPCPublicSubnet2Subnet74179F39) hello-cdk | 9/42 | 7:39:50 pm | DELETE_IN_PROGRESS | AWS::SNS::Topic | Topic3 (Topic3DEAE47A7) hello-cdk | 10/42 | 7:39:50 pm | DELETE_COMPLETE | AWS::EC2::EIP | VPC/PublicSubnet1/EIP (VPCPublicSubnet1EIP6AD938E8) hello-cdk | 11/42 | 7:39:51 pm | DELETE_COMPLETE | AWS::EC2::EIP | VPC/PublicSubnet2/EIP (VPCPublicSubnet2EIP4947BC00) hello-cdk | 12/42 | 7:39:51 pm | DELETE_COMPLETE | AWS::EC2::SecurityGroup | MyAutoScalingGroup/Compute/InstanceSecurityGroup (MyAutoScalingGroupComputeInstanceSecurityGroup2222F5E5) hello-cdk | 11/42 | 7:39:51 pm | DELETE_COMPLETE | AWS::CDK::Metadata | CDKMetadata/Default (CDKMetadata) hello-cdk | 10/42 | 7:39:51 pm | DELETE_COMPLETE | AWS::SNS::Topic | Topic5 (Topic5A03540AE) hello-cdk | 9/42 | 7:39:51 pm | DELETE_COMPLETE | AWS::SNS::Topic | Topic4 (Topic4F5C0CEE2) hello-cdk | 8/42 | 7:39:51 pm | DELETE_COMPLETE | AWS::SNS::Topic | Topic2 (Topic269377B75) hello-cdk | 7/42 | 7:39:51 pm | DELETE_COMPLETE | AWS::SNS::Topic | Topic1 (Topic198E71B3E) hello-cdk | 8/42 | 7:39:51 pm | DELETE_COMPLETE | AWS::IAM::Role | MyAutoScalingGroup/Compute/InstanceRole (MyAutoScalingGroupComputeInstanceRole1B510108) hello-cdk | 9/42 | 7:39:52 pm | DELETE_COMPLETE | AWS::EC2::InternetGateway | VPC/IGW (VPCIGWB7E252D3) hello-cdk | 8/42 | 7:39:58 pm | DELETE_COMPLETE | AWS::SNS::Topic | Topic3 (Topic3DEAE47A7) 8/42 Currently in progress: hello-cdk, MySinkQueueEFCD79C2 hello-cdk | 9/42 | 7:40:51 pm | DELETE_COMPLETE | AWS::SQS::Queue | MySinkQueue/Resource (MySinkQueueEFCD79C2) 9/42 Currently in progress: hello-cdk hello-cdk | 10/42 | 7:41:55 pm | DELETE_COMPLETE | AWS::EC2::RouteTable | VPC/PublicSubnet2/RouteTable (VPCPublicSubnet2RouteTable6F1A15F1) hello-cdk | 11/42 | 7:42:05 pm | DELETE_COMPLETE | AWS::EC2::RouteTable | VPC/PrivateSubnet1/RouteTable (VPCPrivateSubnet1RouteTableBE8A6027) hello-cdk | 12/42 | 7:42:10 pm | DELETE_COMPLETE | AWS::EC2::RouteTable | VPC/PrivateSubnet2/RouteTable (VPCPrivateSubnet2RouteTable0A19E10E) hello-cdk | 13/42 | 7:42:13 pm | DELETE_COMPLETE | AWS::EC2::RouteTable | VPC/PublicSubnet1/RouteTable (VPCPublicSubnet1RouteTableFEE4B781) hello-cdk | 13/42 | 7:42:13 pm | DELETE_IN_PROGRESS | AWS::EC2::VPC | VPC (VPCB9E5F0B4) hello-cdk | 12/42 | 7:42:15 pm | DELETE_COMPLETE | AWS::EC2::VPC | VPC (VPCB9E5F0B4) hello-cdk | 13/42 | 7:42:15 pm | ROLLBACK_COMPLETE | AWS::CloudFormation::Stack | hello-cdk

Failed resources: hello-cdk | 7:39:39 pm | CREATE_FAILED | AWS::EC2::Subnet | VPC/PublicSubnet2/Subnet (VPCPublicSubnet2Subnet74179F39) Template error: Fn::Select cannot select nonexistent value at index 1 hello-cdk | 7:39:39 pm | CREATE_FAILED | AWS::EC2::Subnet | VPC/PrivateSubnet2/Subnet (VPCPrivateSubnet2SubnetCFCDAA7A) Template error: Fn::Select cannot select nonexistent value at index 1

❌ hello-cdk failed: Error: The stack named hello-cdk failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Template error: Fn::Select cannot select nonexistent value at index 1, Template error: Fn::Select cannot select nonexistent value at index 1 at prepareAndExecuteChangeSet (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-cdk\lib\api\deploy-stack.ts:386:13) at processTicksAndRejections (node:internal/process/task_queues:95:5) at deployStack2 (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-cdk\lib\cdk-toolkit.ts:240:24) at d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-cdk\lib\deploy.ts:39:11 at run (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\p-queue\dist\index.js:163:29)

❌ Deployment failed: Error: Stack Deployments Failed: Error: The stack named hello-cdk failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Template error: Fn::Select cannot select nonexistent value at index 1, Template error: Fn::Select cannot select nonexistent value at index 1 at deployStacks (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-cdk\lib\deploy.ts:61:11) at processTicksAndRejections (node:internal/process/task_queues:95:5) at CdkToolkit.deploy (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-cdk\lib\cdk-toolkit.ts:312:7) at initCommandLine (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-cdk\lib\cli.ts:349:12)

Stack Deployments Failed: Error: The stack named hello-cdk failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Template error: Fn::Select cannot select nonexistent value at index 1, Template error: Fn::Select cannot select nonexistent value at index 1

Reproduction Steps

run cdk deploy

Possible Solution

No response

Additional Information/Context

aws\ts>cdk --version 2.43.0 (build 487870a)

aws\ts>node -v v18.9.0

CDK CLI Version

2.43.0 (build 487870a)

Framework Version

No response

Node.js Version

v18.9.0

OS

windows 10

Language

Java

Language Version

java version "17.0.2" 2022-01-18 LTS

saikatak commented 1 year ago

@nagkumar Able to successfully perform cdk deploy. Would recommend to test again and comment the observations, So that this issue can be closed