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

error associating RAM Resource Share #7632

Closed
tbugfinder opened this issue Feb 21, 2019 · 16 comments · Fixed by #8048
Closed

error associating RAM Resource Share #7632

tbugfinder opened this issue Feb 21, 2019 · 16 comments · Fixed by #8048
Labels
documentation Introduces or discusses updates to documentation. service/ram Issues and PRs that pertain to the ram service.
Milestone

Comments

@tbugfinder
Copy link
Contributor

tbugfinder commented Feb 21, 2019

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.11.8

Affected Resource(s)

  • aws_ram_resource_share
  • aws_ram_principal_association
  • aws_ram_resource_association

Terraform Configuration Files

Just use code of the documentation pages and use principal o-/ou-.

resource "aws_ram_resource_share" "tgwshare" {
  name = "test-share1"
  allow_external_principals = false
}

resource "aws_ram_principal_association" "example" {
  principal          = "o-xxxxxxx"


  resource_share_arn = "${aws_ram_resource_share.tgwshare.id}"
}

resource "aws_ram_resource_association" "tgwassoc" {
  resource_arn       = "${aws_ec2_transit_gateway.tgw.arn}"
  resource_share_arn = "${aws_ram_resource_share.tgwshare.id}"
}

resource "aws_ec2_transit_gateway" "tgw" {
  description = "example"
}

Debug Output

  • aws_ram_principal_association.example: 1 error(s) occurred:

  • aws_ram_principal_association.example: Error associating principal with RAM resource share: InvalidParameterException: Principal ID o-XXXXXXXX is malformed. Verify the ID and try again.
    status code: 400, request id: 80e330c1-35e0-11e9-84b1-c1fca2fb946c

Panic Output

no panic

Expected Behavior

Support o-,ou- synatx.

Actual Behavior

Synatay error while using ou- | o- the notation of the principal fails.

Steps to Reproduce

  1. terraform apply

Important Factoids

References

@bflad bflad added the service/ram Issues and PRs that pertain to the ram service. label Feb 21, 2019
@anupkandpile
Copy link

I see the same error when I pass Account ID / Org ID / OU-ID as a principal.

resource "aws_ram_resource_share" "txgw_ram_resource_share" {`
  name                      = "${var.txgw_description}"`
  allow_external_principals = true
  tags {
    Team_ID    = "XXXXXX"
    Service_ID = "XXXXXX"
  }
}
resource "aws_ram_resource_association" "txgw_ram_resource_association" {
  resource_arn       = "${var.txgw_resource_arn}"
  resource_share_arn = "${aws_ram_resource_share.txgw_ram_resource_share.id}"
}
resource "aws_ram_principal_association" "txgw_ram_principal_association" {
  principal          = "${var.aws_org_ou_id}"
  resource_share_arn = "${aws_ram_resource_share.txgw_ram_resource_share.id}"
}
output "txgw_ram_resource_share_id" {
  value = "${aws_ram_resource_share.txgw_ram_resource_share.id}"
}

module.txgw_resource_share.aws_ram_principal_association.txgw_ram_principal_association: 1 error(s) occurred:

aws_ram_principal_association.txgw_ram_principal_association: Error associating principal with RAM resource share: InvalidParameterException: Principal ID XXXXXXXXXX is malformed. Verify the ID and try again.
status code: 400, request id: XXXXX

@tbugfinder
Copy link
Contributor Author

Actually I'm also confused why we pass an ID when the name is ARN.
resource_share_arn = "${aws_ram_resource_share.txgw_ram_resource_share.id}"

@anupkandpile
Copy link

I tried to pass ARN in place of ID and it errored out:

Error:

Error: Error running plan: 2 error(s) occurred:

  • module.txgw_resource_share.aws_ram_principal_association.txgw_ram_principal_association: 1 error(s) occurred:

module.txgw_resource_share.aws_ram_principal_association.txgw_ram_principal_association: Resource 'aws_ram_resource_share.txgw_ram_resource_share' does not have attribute 'arn' for variable 'aws_ram_resource_share.txgw_ram_resource_share.arn'

  • module.txgw_resource_share.aws_ram_resource_association.txgw_ram_resource_association: 1 error(s) occurred:

module.txgw_resource_share.aws_ram_resource_association.txgw_ram_resource_association: Resource 'aws_ram_resource_share.txgw_ram_resource_share' does not have attribute 'arn' for variable 'aws_ram_resource_share.txgw_ram_resource_share.arn'

@tbugfinder
Copy link
Contributor Author

exactly.

@bflad
Copy link
Contributor

bflad commented Feb 21, 2019

I submitted adding an arn attribute here: #7634

@tbugfinder
Copy link
Contributor Author

tbugfinder commented Feb 24, 2019

That match expression should be extended to allow o-/ou- strings:
https://github.com/terraform-providers/terraform-provider-aws/blob/c7d129e27f601973b00e1f17bc70c1782d56c2c9/aws/resource_aws_ram_principal_association.go#L65

@anupkandpile
Copy link

@tbugfinder I was able to get past the "malformed principal" issue by providing the ARN of Org/OU instead of ID. i.e. arn:aws:organizations::XXXXXXX:ou/o-XXXX/ou-XXXX inplace of (o-xxxxxxx/ou-xxxxxxx) and it worked.

I'd recommend trying it out on your end if that is the case with you as well.

@tbugfinder
Copy link
Contributor Author

@anupkandpile I confirm that string is valid! Thank you very much.

@tbugfinder
Copy link
Contributor Author

Although I think that the console also accept short strings of the ARN.

@bflad bflad added the documentation Introduces or discusses updates to documentation. label Mar 22, 2019
bflad added a commit that referenced this issue Mar 22, 2019
…ld be ARNs not IDs

Reference: #7632

Output from acceptance testing:

```
--- PASS: TestAccAwsRamPrincipalAssociation_disappears (14.65s)
--- PASS: TestAccAwsRamPrincipalAssociation_basic (16.24s)
```
@bflad
Copy link
Contributor

bflad commented Mar 22, 2019

Pull request submitted to update the documentation to use ARNs instead of IDs as well as add validation for the argument (account ID or ARN): #8048

The API Reference gives no guidance on the parameter, but the web console may be looking up the ID and expanding it to the full ARN before creating the request. We typically do not support those type of cross-service API calls in resources as they can be problematic and introduce complexity we (in both the code maintainer and practitioner sense) would like to avoid.

FYI, the regex noted in the comment above (#7632 (comment)) is only used after successful association creation and is used to bypass waiting for the pending association to complete in the case you specify an external account ID as the principal. Otherwise, it would never be possible for us to create a separate association "accepter" resource. For full context:

https://github.com/terraform-providers/terraform-provider-aws/blob/b4d6106a4e17f428c137c3cf9ccc3abc229c1f00/aws/resource_aws_ram_principal_association.go#L44-L74

@bflad bflad added this to the v2.4.0 milestone Mar 26, 2019
@bflad
Copy link
Contributor

bflad commented Mar 26, 2019

The documentation and validation updates have been merged and will release with version 2.4.0 of the Terraform AWS Provider, likely in the next two days. 👍

@bflad
Copy link
Contributor

bflad commented Mar 29, 2019

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

@Math1er
Copy link

Math1er commented Mar 29, 2019

Hello
I have a question regarding this topic.
I don't have OU in my Organisation.
I try to provide the ARN of my Organization without OU and it's doesn't work (Terraform provider =2.4.0)
arn:aws:organizations::XXXXXXXXXXXX:ou/o-XXXXXXXXXX
and also
arn:aws:organizations::XXXXXXXXXXXX:ou/o-XXXXXXXXXX/r-XXXX
Did the aws_ram_principal_association ressources can work without OU?
Regards,

@bflad
Copy link
Contributor

bflad commented Mar 29, 2019

Hi @Math1er 👋 Your Organization ARN should be of the form:

arn:aws:organizations::XXXXXXXXXXXX:organization/o-XXXXXXXX

I grabbed the above in my environment using the AWS CLI: aws organizations describe-organization

@mrg2k8
Copy link

mrg2k8 commented Apr 17, 2019

If it still doesn't work, try enabling "Enable account sharing within your AWS organization" on the root account, in the settings of the RAM service.

@ghost
Copy link

ghost commented Mar 30, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 30, 2020
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. service/ram Issues and PRs that pertain to the ram service.
Projects
None yet
5 participants