-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Conversation
return fmt.Errorf("error enabling Service Catalog AWS Organizations Access: %w", err) | ||
} | ||
|
||
d.SetId(meta.(*AWSClient).accountid) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return fmt.Errorf("error enabling Service Catalog AWS Organizations Access: %w", err) | |
return fmt.Errorf("error disabling Service Catalog AWS Organizations Access: %w", err) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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)}, ":")) |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved.
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 |
ab97a3f
to
e338096
Compare
08cd931
to
cb8d633
Compare
…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
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! |
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. |
Community Note
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
):Output from acceptance testing (GovCloud):
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.