hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.86k stars 9.21k forks source link

[Bug]: resource aws_servicecatalog_portfolio_share principal_id doesn't allow govcloud #31714

Open brodycragg opened 1 year ago

brodycragg commented 1 year ago

Terraform Core Version

1.3.1

AWS Provider Version

4.11

Affected Resource(s)

The resource for sharing service catalog product's principal_id requires org arns to be ###:aws:##### whereas govcloud arns are ###:aws-us-gov:##### causing this share to not work for govcloud stating the arn is incorrect. This seems to be a hard requirement for string validation located here: https://github.com/hashicorp/terraform-provider-aws/blob/0a77465627efb9003f87978f901d1a4004a2fc09/internal/service/servicecatalog/portfolio_share.go#L57

Expected Behavior

The govcloud arn should work just the same as pubcloud.

Actual Behavior

Terraform spits out a 400 error stating string validation error.

Relevant Error/Panic Output Snippet

│ Error: error creating Service Catalog Portfolio Share: ValidationException: 1 validation error detected: Value 'arn:aws-us-gov:organizations::REDACTED_ACCT_ID:organization/REDACTED_ORG_ID' at 'organizationNode.value' failed to satisfy constraint: Member must satisfy regular expression pattern: (^[0-9]{12}$)|(^arn:aws:organizations::\d{12}:organization\/o-[a-z0-9]{10,32})|(^o-[a-z0-9]{10,32}$)|(^arn:aws:organizations::\d{12}:ou\/o-[a-z0-9]{10,32}\/ou-[0-9a-z]{4,32}-[0-9a-z]{8,32}$)|(^ou-[0-9a-z]{4,32}-[a-z0-9]{8,32}$)
│   status code: 400, request id: 91d16dcc-0a9a-4aff-9243-a0af4554dff1

Terraform Configuration Files

data "aws_organizations_organization" "org" {}

resource "aws_servicecatalog_portfolio_share" "backup_portfolio_share" {
  principal_id = data.aws_organizations_organization.org.arn
  portfolio_id = var.portfolio_id
  type         = "ORGANIZATION"
}

Steps to Reproduce

terraform apply -f aws_service_catalog.tf

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue