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

cli-lib-alpha: bootstrap with bad argument name for trust and trustForLookup #30404

Labels
bug This issue is a bug. cli Issues related to the CDK CLI effort/small Small work item – less than a day of effort p2 package/tools Related to AWS CDK Tools or CLI

Comments

@juanenriqueescobar
Copy link

Describe the bug

trust and trustForLookup options are overwriting qualifier, so it's impossible to bootstrap a new account.

https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/cli-lib-alpha/lib/cli.ts#L187C1-L190

Expected Behavior

bootstrap a new account with custom options using cli-lib-alpha

Current Behavior

qualifier is defined as array and bootstrap fail with: failed bootstrapping: InvalidParameterType: Expected params.Parameters[6].ParameterValue to be a string

Reproduction Steps

 await cli.bootstrap({
    trust: '00000000000',
    trustForLookup: '11111111111111',
    qualifier: 'hnb659fds',
 })

trace show this:

"Parameters": [
        { "ParameterKey": "TrustedAccounts", "ParameterValue": "000000000," },
        { "ParameterKey": "TrustedAccountsForLookup", "ParameterValue": "" },
        {
            "ParameterKey": "CloudFormationExecutionPolicies",
            "ParameterValue": "arn:aws:iam::aws:policy/AdministratorAccess"
        },
        { "ParameterKey": "FileAssetsBucketName", "UsePreviousValue": true },
        { "ParameterKey": "FileAssetsBucketKmsKeyId", "UsePreviousValue": true },
        { "ParameterKey": "ContainerAssetsRepositoryName", "UsePreviousValue": true },
        { "ParameterKey": "Qualifier", "ParameterValue": ["hnb659fds", "0000000000000", "111111111111111"] },
        { "ParameterKey": "PublicAccessBlockConfiguration", "ParameterValue": "true" },
        { "ParameterKey": "InputPermissionsBoundary", "UsePreviousValue": true },
        { "ParameterKey": "UseExamplePermissionsBoundary", "UsePreviousValue": true },
        { "ParameterKey": "BootstrapVariant", "UsePreviousValue": true }
    ],

problem is in this line:

{ "ParameterKey": "Qualifier", "ParameterValue": ["hnb659fds", "0000000000000", "111111111111111"] },

Possible Solution

fix parameter names for

trust
https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/cli-lib-alpha/lib/cli.ts#L188

and trustForLookup
https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/cli-lib-alpha/lib/cli.ts#L189

Additional Information/Context

No response

CDK CLI Version

2.143.0

Framework Version

No response

Node.js Version

any

OS

any

Language

TypeScript

Language Version

No response

Other information

No response

@juanenriqueescobar juanenriqueescobar added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 31, 2024
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label May 31, 2024
@khushail khushail added needs-reproduction This issue needs reproduction. and removed needs-triage This issue or PR still needs to be triaged. labels May 31, 2024
@khushail khushail self-assigned this May 31, 2024
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. p2 cli Issues related to the CDK CLI effort/small Small work item – less than a day of effort and removed needs-reproduction This issue needs reproduction. labels Jul 11, 2024
@khushail
Copy link
Contributor

khushail commented Jul 16, 2024

Hi @juanenriqueescobar , thanks for reporting this. I am not able to repro the issue with the code . sharing the code which I tried-

import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as cli from '@aws-cdk/cli-lib-alpha';

export class ClialphaIssueStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    const ClialphaIssueStack = cli.AwsCdkCli.fromCdkAppDirectory("/Users/khushail/clialphaIssue");

     ClialphaIssueStack.bootstrap
    ({
      trust: '00000000000',
      trustForLookup: '11111111111111',
      qualifier: 'hnb659fds',
    });
  
  }
}

after running cdk synth --output "khushail/alialphaissue/cdk-app"
getting this error --

Error: Another CLI (PID=86992) is currently synthing to cdk.out. Invoke the CLI in sequence, or use '--output' to synth into different directories.

@khushail
Copy link
Contributor

@juanenriqueescobar , although I see the qualifier in the code being overwritten, could you share some instructions to repro this?

@khushail khushail added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jul 19, 2024
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jul 21, 2024
@juanenriqueescobar
Copy link
Author

juanenriqueescobar commented Jul 22, 2024

@khushail Hi!

I try to bootstrap my account, but get the error that I reported.

const cli = AwsCdkCli.fromCdkAppDirectory()
try {
    await cli.bootstrap({
        trust: '000000000000',
        trustForLookup: '000000000000',
    })
} catch (e) {
    process.exit(1)
}

I follow the source of cli-lib-alpha and there is an error in the arguments generation because they are overwriting the --qualifier option, I think that using the right parameters is enough to fix the problem.

@juanenriqueescobar
Copy link
Author

juanenriqueescobar commented Jul 22, 2024

the --qualifier param is almost a constant, It's used to create the bucket, roles, ecr repositories, etc, I am not trying to change it, but when I try to bootstrap the account, the cli-lib-alpha try to change it.

image

@github-actions github-actions bot removed closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Jul 22, 2024
@khushail
Copy link
Contributor

khushail commented Jul 22, 2024

@juanenriqueescobar I agree with your point in saying that qualifier is being overwritten. I am not able to repro it , perhaps something missing on my side(working on it though).
For now, the issue is being marked as P2 which means it won't be immediately worked upon by the team but would need sometime. However if you would like to fix the issue and submit a PR, please feel free to do so. Thanks!

@khushail khushail removed the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Jul 22, 2024
@khushail khushail removed their assignment Aug 1, 2024
mrgrain added a commit that referenced this issue Aug 20, 2024
@mergify mergify bot closed this as completed in #31159 Aug 21, 2024
mergify bot pushed a commit that referenced this issue Aug 21, 2024
…r trust and trustForLookup (#31159)

### Issue

Closes #30404

### Reason for this change

`trust` and `trustForLookup` options are overwriting `qualifier`, so it's impossible to bootstrap a new account with these options.

### Description of changes

Fix the assignment.

### Description of how you validated changes

Manual test. The testing infrastructure currently doesn't support this kind of test I think.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 21, 2024
GavinZZ pushed a commit that referenced this issue Aug 23, 2024
…r trust and trustForLookup (#31159)

### Issue

Closes #30404

### Reason for this change

`trust` and `trustForLookup` options are overwriting `qualifier`, so it's impossible to bootstrap a new account with these options.

### Description of changes

Fix the assignment.

### Description of how you validated changes

Manual test. The testing infrastructure currently doesn't support this kind of test I think.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.