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

(servicecatalog): TagOptions cannot be shared among portfolios in the same account #17753

Closed
avanderm opened this issue Nov 29, 2021 · 3 comments · Fixed by #18314
Closed

(servicecatalog): TagOptions cannot be shared among portfolios in the same account #17753

avanderm opened this issue Nov 29, 2021 · 3 comments · Fixed by #18314
Labels
@aws-cdk/aws-servicecatalog Related to AWS Service Catalog bug This issue is a bug. effort/medium Medium work item – several days of effort p2

Comments

@avanderm
Copy link

avanderm commented Nov 29, 2021

What is the problem?

Specifying TagOptions and sharing them with two separate ServiceCatalog portfolios in different stacks in the same AWS account will fail because it leads to a duplicate creation of TagOption resources (they are created alongside the TagOptionAssocation).

Reproduction Steps

export class TagOptionsStack extends cdk.Stack {
  public readonly tagOptions: TagOptions;

  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    this.tagOptions = new TagOptions({
      'testtag': ['test'],
    });
  }
}

interface PortfolioOneStackProps extends cdk.StackProps {
  tagOptions: TagOptions;
}

export class PortfolioStackOne extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props: PortfolioOneStackProps) {
    super(scope, id, props);

    new Portfolio(this, 'PortfolioOne', {
      displayName: 'Portfolio 1',
      providerName: 'provider',
      tagOptions: props.tagOptions,
    });
  }
}

interface PortfolioTwoStackProps extends cdk.StackProps {
  tagOptions: TagOptions;
}

export class PortfolioStackTwo extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props: PortfolioTwoStackProps) {
    super(scope, id, props);

    new Portfolio(this, 'PortfolioTwo', {
      displayName: 'Portfolio 2',
      providerName: 'provider',
      tagOptions: props.tagOptions,
    });
  }
}

What did you expect to happen?

I expected the TagOptions class to implement the Construct interface so that TagOptions would be created and that passing the TagOptions class to a portfolio would only create the assocations. For my use case I'll simple add the portfolios in one stack. However I can imagine in other teams, where portfolios are created by different teams, this would not be possible. Or we'd need to resort to the L1 classes.

What actually happened?

The code will synthesize, but the deployment will fail when the second portfolio is being deployed, because the TagOption already exists in the first Portfolio stack. The TagOptions in the TagOptionsStack will not create TagOption in that stack, since the TagOptions class is not a construct.

CDK CLI Version

1.122.0 (build ae09c16)

Framework Version

No response

Node.js Version

v16.13.0

OS

Fedora

Language

Typescript

Language Version

TypeScript (3.9.7)

Other information

No response

@avanderm avanderm added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 29, 2021
@github-actions github-actions bot added the @aws-cdk/aws-servicecatalog Related to AWS Service Catalog label Nov 29, 2021
@ryparker ryparker added effort/medium Medium work item – several days of effort p2 needs-reproduction This issue needs reproduction. and removed needs-triage This issue or PR still needs to be triaged. labels Nov 29, 2021
@arcrank
Copy link
Contributor

arcrank commented Nov 30, 2021

Thanks for detailed issue. You're correct that currently we don't surface TagOptions directly as a cdk construct, they are just an interface and when added to a resource it will create the underlying L1. It's interesting use case though having tag options specifically in their own stack. Will provide an update shortly.

@dponzo
Copy link
Contributor

dponzo commented Dec 15, 2021

We will be implementing TagOptions as their own L2 Constructs shortly. Will update with the PR when its up.

@skinny85 skinny85 removed their assignment Dec 15, 2021
@skinny85 skinny85 removed the needs-reproduction This issue needs reproduction. label Dec 15, 2021
@mergify mergify bot closed this as completed in #18314 Jan 25, 2022
mergify bot pushed a commit that referenced this issue Jan 25, 2022
Fixes:  [#17753](#17753)


Previously TagOptions were defined via an interface and we only created the underlying
resources upon an association.  This broke CX if tagoptions were mangaged centrally.  We move to
make the TagOptions class a wrapper around aggregate individual TagOptions.

BREAKING CHANGE: `TagOptions` now have `scope` and `props` argument in constructor, and data is now passed via a `allowedValueForTags` field in props

----

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

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

LukvonStrom pushed a commit to LukvonStrom/aws-cdk that referenced this issue Jan 26, 2022
Fixes:  [aws#17753](aws#17753)


Previously TagOptions were defined via an interface and we only created the underlying
resources upon an association.  This broke CX if tagoptions were mangaged centrally.  We move to
make the TagOptions class a wrapper around aggregate individual TagOptions.

BREAKING CHANGE: `TagOptions` now have `scope` and `props` argument in constructor, and data is now passed via a `allowedValueForTags` field in props

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this issue Feb 21, 2022
Fixes:  [aws#17753](aws#17753)


Previously TagOptions were defined via an interface and we only created the underlying
resources upon an association.  This broke CX if tagoptions were mangaged centrally.  We move to
make the TagOptions class a wrapper around aggregate individual TagOptions.

BREAKING CHANGE: `TagOptions` now have `scope` and `props` argument in constructor, and data is now passed via a `allowedValueForTags` field in props

----

*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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-servicecatalog Related to AWS Service Catalog bug This issue is a bug. effort/medium Medium work item – several days of effort p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants