awslabs / aws-bootstrap-kit

Apache License 2.0
105 stars 21 forks source link

Unclear how to "import" existing accounts. #110

Open moltar opened 2 years ago

moltar commented 2 years ago

I have tried to add an existing account to nestedOU.

All of the values were copy-pasted from the console.

          {
            name: 'name',
            existingAccountId: '123',
            email: 'foo@bar.com',
          },

Deployment exploded with:

Parameter name: can't be prefixed with "ssm" (case-insensitive). If formed as a path, it can consist of sub-paths divided by slash symbol; each sub-path can be formed as a mix of letters, numbers and the following 3 symbols .-_ (Service: AmazonSSM; Status Code: 400; Error Code: ValidationException; Request ID: abb75351-1797-4236-b34d-4539a829ca5b; Proxy: null)

Which doesn't even make sense, as the parameter is not using ssm in the name. But maybe it's a generic error?

Account name does have a space in it. But it looks like an ID is used for existing accounts anyways. So I don't see a problem there.

Any ideas?

Thanks.

moltar commented 2 years ago

Btw, what also might have caused it is the fact that I renamed the OU in the same deployment.

npvisual commented 2 years ago

Tried using the existingAccountId as well and got the following error when running a cdk diff :

1-SDLC-organization % npm run diff

> sdlc-organization@0.7.0 diff
> cdk --profile main-admin diff

/Users/{...}/GitHub/aws-bootstrap-kit-examples/source/1-SDLC-organization/node_modules/aws-cdk-lib/core/lib/private/uniqueid.ts:42
    throw new Error(`ID components may not include unresolved tokens: ${unresolvedTokens.join(',')}`);
          ^
Error: Resolution error: ID components may not include unresolved tokens: ${Token[TOKEN.1399]}SubZoneDelegationNSRecord.
Object creation stack:
  at Execute again with CDK_DEBUG=true to capture stack traces
    at Object.makeUniqueId (/Users/{...}/GitHub/aws-bootstrap-kit-examples/source/1-SDLC-organization/node_modules/aws-cdk-lib/core/lib/private/uniqueid.ts:42:11)
    at AwsOrganizationsStack.allocateLogicalId (/Users/{...}/GitHub/aws-bootstrap-kit-examples/source/1-SDLC-organization/node_modules/aws-cdk-lib/core/lib/stack.ts:500:12)
    at AwsOrganizationsStack.getLogicalId (/Users/{...}/GitHub/aws-bootstrap-kit-examples/source/1-SDLC-organization/node_modules/aws-cdk-lib/core/lib/stack.ts:260:28)
    at CfnRecordSet.synthesizeLogicalId (/Users/{...}/GitHub/aws-bootstrap-kit-examples/source/1-SDLC-organization/node_modules/aws-cdk-lib/core/lib/cfn-element.ts:98:25)
    at Object.produce (/Users/{...}/GitHub/aws-bootstrap-kit-examples/source/1-SDLC-organization/node_modules/aws-cdk-lib/core/lib/cfn-element.ts:33:64)
    at LazyString.resolve (/Users/{...}/GitHub/aws-bootstrap-kit-examples/source/1-SDLC-organization/node_modules/aws-cdk-lib/core/lib/lazy.ts:167:28)
    at RememberingTokenResolver.resolveToken (/Users/{...}/GitHub/aws-bootstrap-kit-examples/source/1-SDLC-organization/node_modules/aws-cdk-lib/core/lib/resolvable.ts:80:24)
    at RememberingTokenResolver.resolveToken (/Users/{...}/GitHub/aws-bootstrap-kit-examples/source/1-SDLC-organization/node_modules/aws-cdk-lib/core/lib/private/resolve.ts:282:18)
    at resolve (/Users/{...}/GitHub/aws-bootstrap-kit-examples/source/1-SDLC-organization/node_modules/aws-cdk-lib/core/lib/private/resolve.ts:208:51)
    at Object.resolve [as mapToken] (/Users/{...}/GitHub/aws-bootstrap-kit-examples/source/1-SDLC-organization/node_modules/aws-cdk-lib/core/lib/private/resolve.ts:115:77)
Subprocess exited with error 1

The error disappears when I remove it from sdlc-organization.ts.

parker-h commented 1 year ago

Im getting the same error exact error when trying to add existing accounts using existingAccountId @npvisual. For me it seems to be only throwing the error on AccountType.STAGE type.

flochaz commented 1 year ago

Sorry to hear that. let me come back to you with proper doc. will prioritize that this week