Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

https://github.com/aws-samples/aws-cdk-examples/tree/master/java/codebuild/project documentation issue #745

Open
nagkumar opened this issue Sep 26, 2022 · 2 comments
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort language/java Related to Java examples needs-triage This issue or PR still needs to be triaged. ngde/pod Great issues for pods

Comments

@nagkumar
Copy link

Describe the bug

To run https://github.com/aws-samples/aws-cdk-examples/tree/master/java/codebuild examples bootstraping should be done in certain way, that command is not present in readme.md

Expected Behavior

command to boot strap this project should be mentioned properly in readme.md

Current Behavior

iac\aws\cdk\java\codebuild\project> cdk bootstrap --trust projectStack --cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess aws://projectStack/ap-south-1
⏳ Bootstrapping environment aws://projectStack/ap-south-1...
❌ Environment aws://projectStack/ap-south-1 failed bootstrapping: Error: Need to perform AWS calls for account projectStack, but the current credentials are for 132462119873
at SdkProvider.forEnvironment (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-cdk\lib\api\aws-auth\sdk-provider.ts:184:60)
at Function.lookup (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-cdk\lib\api\bootstrap\deploy-bootstrap.ts:31:18)
at Bootstrapper.modernBootstrap (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-cdk\lib\api\bootstrap\bootstrap-environment.ts:81:21)
at d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-cdk\lib\cdk-toolkit.ts:621:24
at async Promise.all (index 0)
at CdkToolkit.bootstrap (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-cdk\lib\cdk-toolkit.ts:618:5)
at initCommandLine (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-cdk\lib\cli.ts:349:12)

Need to perform AWS calls for account projectStack, but the current credentials are for 132462119873

Reproduction Steps

go to iac\aws\cdk\java\codebuild\project folder and run deploy it gives the above error

Possible Solution

proper documentation in readme.md

Additional Information/Context

No response

CDK CLI Version

'2.43.1'

Framework Version

No response

Node.js Version

18

OS

windows 10

Language

Java

Language Version

jdk18

@nagkumar nagkumar added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 26, 2022
@nagkumar
Copy link
Author

nagkumar commented Sep 27, 2022

new ProjectStack(app, "ProjectStack", StackProps.builder().env( Environment.builder() .account("projectStack") .region("ap-south-1") .build()).build());

This code is using a special account projectStack, better to use

 public static final Environment makeEnv()
    {
	return Environment.builder()
			  .account(System.getenv("CDK_DEFAULT_ACCOUNT"))
			  .region(System.getenv("CDK_DEFAULT_REGION"))
			  .build();
    }

In any case, readme.md should say how to create projectStack account with what kind of privileges etc..
Also, this example also needs some commit directory etc.. not sure SampleProject should pre-exist etc..in Code Commit.. Better readme.md would help a lot.

@nagkumar
Copy link
Author

nagkumar commented Sep 28, 2022

	IRole role =
		Role.fromRoleArn(this, "someId", "arn:partition:service:region:account-id:resource-type:resource-id");

Looks like this line arn part also needs to be changed for this code to work, looked at class com.myorg.ProjectStack
Readme.md should contain the changes needed to such code

error reported for reference is

ProjectStack | 0/3 | 4:48:39 pm | CREATE_FAILED        | AWS::CodeBuild::Project | SampleProject (SampleProject086B1A88) Invalid service role (Service: AWSCodeBuild; Status Code: 400; Error Code: InvalidInputException; Request ID: 1a0c31ef-7a83-4fbf-be4c-88f516cc9d1b; Proxy: null)
ProjectStack | 0/3 | 4:48:40 pm | CREATE_FAILED        | AWS::CDK::Metadata      | CDKMetadata/Default (CDKMetadata) Resource creation cancelled
ProjectStack | 0/3 | 4:48:41 pm | ROLLBACK_IN_PROGRESS | AWS::CloudFormation::Stack | ProjectStack The following resource(s) failed to create: [SampleProject086B1A88, CDKMetadata]. Rollback requested by user.

@kaiz-io kaiz-io added effort/small Small work item – less than a day of effort language/java Related to Java examples ngde/pod Great issues for pods labels Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort language/java Related to Java examples needs-triage This issue or PR still needs to be triaged. ngde/pod Great issues for pods
Projects
None yet
Development

No branches or pull requests

2 participants