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

CDK Bootstrap requires --app #7906

Closed
chrisb92 opened this issue May 11, 2020 · 11 comments · Fixed by #7970
Closed

CDK Bootstrap requires --app #7906

chrisb92 opened this issue May 11, 2020 · 11 comments · Fixed by #7970
Assignees
Labels
bug This issue is a bug. p1 package/tools Related to AWS CDK Tools or CLI

Comments

@chrisb92
Copy link
Contributor

❓ General Issue

The Question

I recently updated my project aws-cdk dependencies from v1.35.0 to v1.38.0 and I seem to be experiencing a new issue where if I call npx cdk bootstrap aws://${TARGET_ACCOUNT}/${AWS_REGION} in my bash script, I get the error --app is required either in command-line, in cdk.json or in ~/.cdk.json previously I was able to use this command without --app.

I noticed that there was something changed in this area in v1.36.0, see #7510.

I'm struggling to find any supporting documentation on this change where --app is required to run cdk bootstrap.

Is this intended functionality, or has a bug been introduced?

Environment

  • CDK CLI Version: 1.38.0 (build d5fa31f)
  • Module Version: 1.38.0
  • OS: all
  • Language: TypeScript

Other information

@chrisb92 chrisb92 added the needs-triage This issue or PR still needs to be triaged. label May 11, 2020
@ilkomiliev
Copy link

same here - I can confirm the latest working version was 1.35.0, I've skipped 1.36.0, but in 1.36.1 this regression started. And I can confirm that nothing changed on our side, cdk.json and app.py can be found in the directory where cdk boostrap is executed.

@SomayaB SomayaB added bug This issue is a bug. package/tools Related to AWS CDK Tools or CLI labels May 12, 2020
@tmclaugh
Copy link

I'm confused by this comment in #7510 :

"It used to be that if we had an --app argument, we would always glob
arguments to cdk bootstrap through the environments of stacks
in the app.

This makes it super hard/annoying to run cdk bootstrap aws://1234/us-somewhere in a CI/CD project; you have to add a stack"

Prior to this change that's what I did and I neither passed --app or had a cdk.json / .cdk.json file. Last time I had to run this pipeline it looks like was about 2 months ago using whatever was the latest release.

Might as well ping @rix0rrr to this issue.

@shivlaks
Copy link
Contributor

shivlaks commented May 12, 2020

I'm struggling to find any supporting documentation on this change where --app is required to run cdk bootstrap.
@chrisb92 @tmclaugh @ilkomiliev app should not be required when running bootstrap. Or rather that's what #7510 set out to address

are you providing a concrete environment name and it's not working? I'm trying to reproduce this behavior.

so I created a basic shell script

#!/bin/bash
  
npx cdk bootstrap aws://123456789012/ca-central-1

and then I executed it (outside of an app). It ran successfully, so I'm thinking I've missed something. What am I missing here?

@ilkomiliev
Copy link

Hi shivlaks,

this is interesting - I've just tried it out also outside of an app and it brings me exactly the same message:
npx cdk bootstrap aws://123456789012/us-east-1 --app is required either in command-line, in cdk.json or in ~/.cdk.json

I'm executing this on an EC2 instance without any extra credentials, just using its IAM role, which has admin permissions in the account. Second use case I've tried when I'm assuming a role for another account - the same error. Switching back to 1.35.0 works w/out issues. What kind of extra information can I provide you to investigate this further? Quite a blocker for us - we stick currently to 1.35.0 because of this.

Thanks

@ilkomiliev
Copy link

Lot of changes in #7510 - really difficult to figure out what exactly could cause the problem - the changes somewhere in replacing the accountId, regionId by Environment or some manipulation of the globs, etc. OTOH, what confuses me is the comment of the problem is should solve - I always ran this outside an application as far as I can see in my script and w/out --app argument and it never failed for me. So actually --app was never needed in my case.

@shivlaks
Copy link
Contributor

shivlaks commented May 13, 2020

@ilkomiliev can you run the command with the -v flag and redact output as needed

@rix0rrr any ideas here?

@chrisb92
Copy link
Contributor Author

chrisb92 commented May 13, 2020

I ran the bootstrap command locally where it would usually work (when it was previously using CDK v1.35.0) and I'm still getting the --app is required error. The context appears to have all the information from my cdk.json file.

chris@devbox:~/git/tracking-api$ npx cdk bootstrap aws://123456789012/eu-west-2 -v
CDK toolkit version: 1.38.0 (build d5fa31f)
Command line arguments: {
  _: [ 'bootstrap' ],
  v: true,
  verbose: true,
  'ignore-errors': false,
  ignoreErrors: false,
  json: false,
  j: false,
  ec2creds: undefined,
  i: undefined,
  'version-reporting': undefined,
  versionReporting: undefined,
  'path-metadata': true,
  pathMetadata: true,
  'asset-metadata': true,
  assetMetadata: true,
  'role-arn': undefined,
  r: undefined,
  roleArn: undefined,
  staging: true,
  'no-color': false,
  noColor: false,
  fail: false,
  'bootstrap-bucket-name': undefined,
  b: undefined,
  'toolkit-bucket-name': undefined,
  toolkitBucketName: undefined,
  bootstrapBucketName: undefined,
  'bootstrap-kms-key-id': undefined,
  bootstrapKmsKeyId: undefined,
  tags: [],
  t: [],
  execute: true,
  trust: [],
  'cloudformation-execution-policies': [],
  cloudformationExecutionPolicies: [],
  force: false,
  f: false,
  '$0': 'node_modules/.bin/cdk',
  ENVIRONMENTS: [ 'aws://123456789012/eu-west-2' ],
  environments: [ 'aws://123456789012/eu-west-2' ]
}
cdk.json: {
  "context": {
      [...]
  }
}
merged settings: {
  versionReporting: true,
  pathMetadata: true,
  output: 'cdk.out',
  context: {
      [...]
  },
  tags: [],
  assetMetadata: true,
  toolkitBucket: {},
  staging: true
}
Determining whether we're on an EC2 instance.
Does not look like EC2 instance.
Toolkit stack: CDKToolkit
Setting "CDK_DEFAULT_REGION" environment variable to eu-west-2
Resolving default credentials
Retrieved account ID 123456789012 from disk cache
Setting "CDK_DEFAULT_ACCOUNT" environment variable to 123456789012
context: {
    [...]
}
--app is required either in command-line, in cdk.json or in ~/.cdk.json
Error: --app is required either in command-line, in cdk.json or in ~/.cdk.json
    at Object.execProgram (/home/chris/git/tracking-api/node_modules/aws-cdk/lib/api/cxapp/exec.ts:47:11)
    at CloudExecutable.doSynthesize (/home/chris/git/tracking-api/node_modules/aws-cdk/lib/api/cxapp/cloud-executable.ts:66:24)
    at CloudExecutable.synthesize (/home/chris/git/tracking-api/node_modules/aws-cdk/lib/api/cxapp/cloud-executable.ts:52:29)
    at CdkToolkit.selectStacksForList (/home/chris/git/tracking-api/node_modules/aws-cdk/lib/cdk-toolkit.ts:373:22)
    at CdkToolkit.bootstrap (/home/chris/git/tracking-api/node_modules/aws-cdk/lib/cdk-toolkit.ts:349:43)
    at main (/home/chris/git/tracking-api/node_modules/aws-cdk/bin/cdk.ts:214:16)
    at initCommandLine (/home/chris/git/tracking-api/node_modules/aws-cdk/bin/cdk.ts:169:9)

@ilkomiliev
Copy link

this is from my env:

CDK toolkit version: 1.38.0 (build d5fa31f)
Command line arguments: { _: [ 'bootstrap' ],
v: true,
verbose: true,
'ignore-errors': false,
ignoreErrors: false,
json: false,
j: false,
ec2creds: undefined,
i: undefined,
'version-reporting': undefined,
versionReporting: undefined,
'path-metadata': true,
pathMetadata: true,
'asset-metadata': true,
assetMetadata: true,
'role-arn': undefined,
r: undefined,
roleArn: undefined,
staging: true,
'no-color': false,
noColor: false,
fail: false,
'bootstrap-bucket-name': undefined,
b: undefined,
'toolkit-bucket-name': undefined,
toolkitBucketName: undefined,
bootstrapBucketName: undefined,
'bootstrap-kms-key-id': undefined,
bootstrapKmsKeyId: undefined,
tags: [],
t: [],
execute: true,
trust: [],
'cloudformation-execution-policies': [],
cloudformationExecutionPolicies: [],
force: false,
f: false,
'$0': '../node_modules/.bin/cdk',
ENVIRONMENTS: [ 'aws://123456789012/us-east-1' ],
environments: [ 'aws://123456789012/us-east-1' ] }
merged settings: { versionReporting: true,
pathMetadata: true,
output: 'cdk.out',
context: {},
tags: [],
assetMetadata: true,
toolkitBucket: {},
staging: true }
Determining whether we're on an EC2 instance.
Looks like EC2 instance.
Unable to determine AWS region from environment or AWS configuration (profile: "default"), defaulting to 'us-east-1'
Toolkit stack: CDKToolkit
Setting "CDK_DEFAULT_REGION" environment variable to us-east-1
Resolving default credentials
Retrieved account ID XXXXXXXXXXXX from disk cache
Setting "CDK_DEFAULT_ACCOUNT" environment variable to XXXXXXXXXXXX
context: { 'aws:cdk:enable-path-metadata': true,
'aws:cdk:enable-asset-metadata': true }
--app is required either in command-line, in cdk.json or in ~/.cdk.json
Error: --app is required either in command-line, in cdk.json or in ~/.cdk.json
at Object.execProgram (/home/ec2-user/workspaces/finca-iac/node_modules/aws-cdk/lib/api/cxapp/exec.ts:47:11)

@shivlaks
Copy link
Contributor

@chrisb92 @ilkomiliev thanks! I'm able to repro it and am taking a deeper look

@tmclaugh
Copy link

Below is from my CI/CD pipeline logs. I want to add that I don't bootstrap from an existing product. This is a CI/CD pipeline job to bootstrap a new account.

error	13-May-2020 13:20:55	CDK toolkit version: 1.38.0 (build d5fa31f)
error	13-May-2020 13:20:55	Command line arguments: { _: [ 'bootstrap' ],
error	13-May-2020 13:20:55	  tags: [ 'deployment_guid=dd1844a6-4f1a-459a-acb0-7ed74640e770' ],
error	13-May-2020 13:20:55	  t: [ 'deployment_guid=dd1844a6-4f1a-459a-acb0-7ed74640e770' ],
error	13-May-2020 13:20:55	  v: true,
error	13-May-2020 13:20:55	  verbose: true,
error	13-May-2020 13:20:55	  'ignore-errors': false,
error	13-May-2020 13:20:55	  ignoreErrors: false,
error	13-May-2020 13:20:55	  json: false,
error	13-May-2020 13:20:55	  j: false,
error	13-May-2020 13:20:55	  ec2creds: undefined,
error	13-May-2020 13:20:55	  i: undefined,
error	13-May-2020 13:20:55	  'version-reporting': undefined,
error	13-May-2020 13:20:55	  versionReporting: undefined,
error	13-May-2020 13:20:55	  'path-metadata': true,
error	13-May-2020 13:20:55	  pathMetadata: true,
error	13-May-2020 13:20:55	  'asset-metadata': true,
error	13-May-2020 13:20:55	  assetMetadata: true,
error	13-May-2020 13:20:55	  'role-arn': undefined,
error	13-May-2020 13:20:55	  r: undefined,
error	13-May-2020 13:20:55	  roleArn: undefined,
error	13-May-2020 13:20:55	  staging: true,
error	13-May-2020 13:20:55	  'no-color': false,
error	13-May-2020 13:20:55	  noColor: false,
error	13-May-2020 13:20:55	  fail: false,
error	13-May-2020 13:20:55	  'bootstrap-bucket-name': undefined,
error	13-May-2020 13:20:55	  b: undefined,
error	13-May-2020 13:20:55	  'toolkit-bucket-name': undefined,
error	13-May-2020 13:20:55	  toolkitBucketName: undefined,
error	13-May-2020 13:20:55	  bootstrapBucketName: undefined,
error	13-May-2020 13:20:55	  'bootstrap-kms-key-id': undefined,
error	13-May-2020 13:20:55	  bootstrapKmsKeyId: undefined,
error	13-May-2020 13:20:55	  execute: true,
error	13-May-2020 13:20:55	  trust: [],
error	13-May-2020 13:20:55	  'cloudformation-execution-policies': [],
error	13-May-2020 13:20:55	  cloudformationExecutionPolicies: [],
error	13-May-2020 13:20:55	  force: false,
error	13-May-2020 13:20:55	  f: false,
error	13-May-2020 13:20:55	  '$0': '../../../../.npm/_npx/10149/bin/cdk',
error	13-May-2020 13:20:55	  ENVIRONMENTS: [ 'aws://123456789012/us-east-1' ],
error	13-May-2020 13:20:55	  environments: [ 'aws://123456789012/us-east-1' ] }
error	13-May-2020 13:20:55	CLI argument tags: deployment_guid=dd1844a6-4f1a-459a-acb0-7ed74640e770
error	13-May-2020 13:20:55	merged settings: { versionReporting: true,
error	13-May-2020 13:20:55	  pathMetadata: true,
error	13-May-2020 13:20:55	  output: 'cdk.out',
error	13-May-2020 13:20:55	  context: {},
error	13-May-2020 13:20:55	  tags:
error	13-May-2020 13:20:55	   [ { Key: 'deployment_guid',
error	13-May-2020 13:20:55	       Value: 'dd1844a6-4f1a-459a-acb0-7ed74640e770' } ],
error	13-May-2020 13:20:55	  assetMetadata: true,
error	13-May-2020 13:20:55	  toolkitBucket: {},
error	13-May-2020 13:20:55	  staging: true }
error	13-May-2020 13:20:55	Determining whether we're on an EC2 instance.
error	13-May-2020 13:20:55	Looks like EC2 instance.
error	13-May-2020 13:20:55	Unable to determine AWS region from environment or AWS configuration (profile: "default"), defaulting to 'us-east-1'
error	13-May-2020 13:20:55	Toolkit stack: CDKToolkit
error	13-May-2020 13:20:55	Setting "CDK_DEFAULT_REGION" environment variable to us-east-1
error	13-May-2020 13:20:55	Resolving default credentials
error	13-May-2020 13:20:55	Looking up default account ID from STS
error	13-May-2020 13:20:55	Default account ID: 387223410295
error	13-May-2020 13:20:55	Setting "CDK_DEFAULT_ACCOUNT" environment variable to 387223410295
error	13-May-2020 13:20:55	context: { 'aws:cdk:enable-path-metadata': true,
error	13-May-2020 13:20:55	  'aws:cdk:enable-asset-metadata': true }
error	13-May-2020 13:20:55	--app is required either in command-line, in cdk.json or in ~/.cdk.json
error	13-May-2020 13:20:55	Error: --app is required either in command-line, in cdk.json or in ~/.cdk.json
error	13-May-2020 13:20:55	    at Object.execProgram (/home/bamboo/.npm/_npx/10149/lib/node_modules/cdk/node_modules/aws-cdk/lib/api/cxapp/exec.ts:47:11)

@shivlaks
Copy link
Contributor

@tmclaugh - thanks! - I think i've gotten into the failure point. writing up a fix, tests, etc

@shivlaks shivlaks added p1 and removed needs-triage This issue or PR still needs to be triaged. labels May 13, 2020
shivlaks added a commit that referenced this issue May 14, 2020
…gument

If a user supplied the `--app` argument, we select the environments from the
app. However, we did not have a check that precludes this selection when the
argument is not provided. We recently refactored this area in #7510

Closes #7906
@mergify mergify bot closed this as completed in #7970 May 14, 2020
mergify bot pushed a commit that referenced this issue May 14, 2020
…gument (#7970)

If a user supplied the `--app` argument, we select the environments from the
app. However, we did not have a check that precludes this selection when the
argument is not provided. We recently refactored this area in #7510

Closes #7906
karupanerura pushed a commit to karupanerura/aws-cdk that referenced this issue May 22, 2020
…gument (aws#7970)

If a user supplied the `--app` argument, we select the environments from the
app. However, we did not have a check that precludes this selection when the
argument is not provided. We recently refactored this area in aws#7510

Closes aws#7906
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. p1 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants