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

r/servicecatalog_portfolio_share: New resource(s) #19278

Merged
merged 41 commits into from
May 14, 2021

Conversation

YakDriver
Copy link
Member

@YakDriver YakDriver commented May 7, 2021

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Relates #15369
Relates #18074
Relates #19122

Right now I'm having trouble testing this since at least the organizations access requires root, non-org account access, which I don't have. Also, these resources are unlikely to be the heaviest used and perhaps relying on the community with these would be okay. 🤷

Output from acceptance testing (us-west-2):

--- SKIP: TestAccAWSServiceCatalogPortfolioShare_organization (0.87s)
--- PASS: TestAccAWSServiceCatalogPortfolioShare_basic (17.98s)

--- SKIP: TestAccAWSServiceCatalogOrganizationsAccess_basic (1.00s)

Output from acceptance testing (GovCloud):

--- SKIP: TestAccAWSServiceCatalogPortfolioShare_basic (1.28s)
--- SKIP: TestAccAWSServiceCatalogPortfolioShare_organization (1.79s)

--- SKIP: TestAccAWSServiceCatalogOrganizationsAccess_basic (1.00s)

Note: I'm not sure an AWS Organizations tests can ever run in GovCloud. GovCloud accounts are always tied to an existing commercial account so may not have the capacity of being a "payer" account.

@YakDriver YakDriver requested a review from a team as a code owner May 7, 2021 17:02
@ghost ghost added size/XXL Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. provider Pertains to the provider itself, rather than any interaction with AWS. service/organizations Issues and PRs that pertain to the organizations service. service/servicecatalog Issues and PRs that pertain to the servicecatalog service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/XL Managed by automation to categorize the size of a PR. and removed size/XXL Managed by automation to categorize the size of a PR. size/XL Managed by automation to categorize the size of a PR. labels May 7, 2021
@ewbankkit ewbankkit self-assigned this May 10, 2021
return fmt.Errorf("error enabling Service Catalog AWS Organizations Access: %w", err)
}

d.SetId(meta.(*AWSClient).accountid)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ID not set in the enabled branch above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!!

_, err := conn.DisableAWSOrganizationsAccess(&servicecatalog.DisableAWSOrganizationsAccessInput{})

if err != nil {
return fmt.Errorf("error enabling Service Catalog AWS Organizations Access: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Errorf("error enabling Service Catalog AWS Organizations Access: %w", err)
return fmt.Errorf("error disabling Service Catalog AWS Organizations Access: %w", err)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦

return fmt.Errorf("error disabling Service Catalog AWS Organizations Access: %w", err)
}

return resourceAwsServiceCatalogOrganizationsAccessRead(d, meta)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a standard pattern (that I've ever seen) to call Read from Delete, usually just return nil.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy pasta! 🤦

return fmt.Errorf("error disabling Service Catalog AWS Organizations Access: %w", err)
}

return resourceAwsServiceCatalogOrganizationsAccessRead(d, meta)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blerg. 🤦

Required: true,
ValidateFunc: validation.StringLenBetween(1, 20),
Type: schema.TypeString,
Required: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to enforce documented max length of 100?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have mixed feelings about enforcing these - mostly against. AWS changes them (across the API) regularly and so we're enforcing the wrong limits much of the time. But, it may save a long wait in certain situations. Most of the time though, AWS responds quickly if validation is failing.

Optional: true,
ValidateFunc: validation.StringLenBetween(1, 20),
Type: schema.TypeString,
Optional: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to enforce documented max length of 50?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

return fmt.Errorf("error creating Service Catalog Portfolio Share: empty response")
}

d.SetId(strings.Join([]string{d.Get("portfolio_id").(string), d.Get("type").(string), d.Get("principal_id").(string)}, ":"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bonus points: Move to aws/internal/service/servicecatalog/id.go.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved.

return nil
}

func resourceServiceCatalogPortfolioShareParseId(id string) (string, string, string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bonus points: Move to aws/internal/service/servicecatalog/id.go.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved.

@ewbankkit
Copy link
Contributor

Verified acceptance tests in Commercial partition:

% make testacc TEST=./aws TESTARGS='-run=TestAccAWSServiceCatalogPortfolioShare_\|TestAccAWSServiceCatalogOrganizationsAccess_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSServiceCatalogPortfolioShare_\|TestAccAWSServiceCatalogOrganizationsAccess_ -timeout 180m
=== RUN   TestAccAWSServiceCatalogOrganizationsAccess_basic
=== PAUSE TestAccAWSServiceCatalogOrganizationsAccess_basic
=== RUN   TestAccAWSServiceCatalogPortfolioShare_basic
=== PAUSE TestAccAWSServiceCatalogPortfolioShare_basic
=== RUN   TestAccAWSServiceCatalogPortfolioShare_organization
=== PAUSE TestAccAWSServiceCatalogPortfolioShare_organization
=== CONT  TestAccAWSServiceCatalogOrganizationsAccess_basic
=== CONT  TestAccAWSServiceCatalogPortfolioShare_organization
=== CONT  TestAccAWSServiceCatalogPortfolioShare_basic
=== CONT  TestAccAWSServiceCatalogOrganizationsAccess_basic
    provider_test.go:780: skipping tests; this AWS account must not be an existing member of an AWS Organization
--- SKIP: TestAccAWSServiceCatalogOrganizationsAccess_basic (0.98s)
=== CONT  TestAccAWSServiceCatalogPortfolioShare_organization
    provider_test.go:780: skipping tests; this AWS account must not be an existing member of an AWS Organization
--- SKIP: TestAccAWSServiceCatalogPortfolioShare_organization (0.98s)
--- PASS: TestAccAWSServiceCatalogPortfolioShare_basic (19.02s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	21.943s

@YakDriver YakDriver force-pushed the f-servicecat-portfolio-share branch from ab97a3f to e338096 Compare May 11, 2021 17:45
@YakDriver YakDriver requested a review from ewbankkit May 11, 2021 17:53
@YakDriver YakDriver force-pushed the f-servicecat-portfolio-share branch from 08cd931 to cb8d633 Compare May 14, 2021 17:22
…ion management account.

Acceptance test output:

% make testacc TEST=./aws TESTARGS='-run=TestAccAWSServiceCatalogOrganizationsAccess_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSServiceCatalogOrganizationsAccess_ -timeout 180m
=== RUN   TestAccAWSServiceCatalogOrganizationsAccess_basic
=== PAUSE TestAccAWSServiceCatalogOrganizationsAccess_basic
=== CONT  TestAccAWSServiceCatalogOrganizationsAccess_basic
--- PASS: TestAccAWSServiceCatalogOrganizationsAccess_basic (16.23s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	19.053s
% make testacc TEST=./aws TESTARGS='-run=TestAccAWSServiceCatalogPortfolioShare_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSServiceCatalogPortfolioShare_ -timeout 180m
=== RUN   TestAccAWSServiceCatalogPortfolioShare_basic
=== PAUSE TestAccAWSServiceCatalogPortfolioShare_basic
=== RUN   TestAccAWSServiceCatalogPortfolioShare_organizationalUnit
=== PAUSE TestAccAWSServiceCatalogPortfolioShare_organizationalUnit
=== CONT  TestAccAWSServiceCatalogPortfolioShare_basic
=== CONT  TestAccAWSServiceCatalogPortfolioShare_organizationalUnit
--- PASS: TestAccAWSServiceCatalogPortfolioShare_basic (19.43s)
--- PASS: TestAccAWSServiceCatalogPortfolioShare_organizationalUnit (24.29s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	27.222s
@YakDriver YakDriver added this to the v3.41.0 milestone May 14, 2021
@YakDriver YakDriver merged commit 27a5052 into main May 14, 2021
@YakDriver YakDriver deleted the f-servicecat-portfolio-share branch May 14, 2021 18:53
github-actions bot pushed a commit that referenced this pull request May 14, 2021
@ghost
Copy link

ghost commented May 19, 2021

This has been released in version 3.41.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. provider Pertains to the provider itself, rather than any interaction with AWS. service/organizations Issues and PRs that pertain to the organizations service. service/servicecatalog Issues and PRs that pertain to the servicecatalog service. service/sts Issues and PRs that pertain to the sts service. size/XXL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants