Skip to content

Commit c03d1a9

Browse files
committed
resource/aws_ram_resource_share_accepter: Minor adjustments and documentation enhancements for initial release
Reference: #8259 Output from acceptance testing: ``` --- PASS: TestAccAwsRamResourceShareAccepter_basic (31.57s) ```
1 parent dce0ffe commit c03d1a9

5 files changed

+23
-12
lines changed

aws/resource_aws_ram_resource_share_accepter.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,17 @@ func resourceAwsRamResourceShareAccepterCreate(d *schema.ResourceData, meta inte
8282

8383
shareARN := d.Get("share_arn").(string)
8484

85-
// need invitation arn
8685
invitation, err := resourceAwsRamResourceShareGetInvitation(conn, shareARN, ram.ResourceShareInvitationStatusPending)
8786

8887
if err != nil {
8988
return err
9089
}
9190

9291
if invitation == nil || aws.StringValue(invitation.ResourceShareInvitationArn) == "" {
93-
return fmt.Errorf("No RAM resource share invitation by ARN (%s) found", shareARN)
92+
return fmt.Errorf(
93+
"No RAM Resource Share (%s) invitation found\n\n" +
94+
"NOTE: If both AWS accounts are in the same AWS Organization and RAM Sharing with AWS Organizations is enabled, this resource is not necessary",
95+
shareARN)
9496
}
9597

9698
input := &ram.AcceptResourceShareInvitationInput{
@@ -225,7 +227,7 @@ func resourceAwsRamResourceShareGetInvitation(conn *ram.RAM, resourceShareARN, s
225227
for _, rsi := range page.ResourceShareInvitations {
226228
if aws.StringValue(rsi.Status) == status {
227229
invitation = rsi
228-
break
230+
return false
229231
}
230232
}
231233

aws/resource_aws_ram_resource_share_accepter_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,12 @@ func testAccCheckAwsRamResourceShareAccepterDestroy(s *terraform.State) error {
7272
return fmt.Errorf("Error deleting RAM resource share: %s", err)
7373
}
7474

75-
if len(output.ResourceShares) == 0 {
76-
return nil
75+
if len(output.ResourceShares) > 0 && aws.StringValue(output.ResourceShares[0].Status) != ram.ResourceShareStatusDeleted {
76+
return fmt.Errorf("RAM resource share invitation found, should be destroyed")
7777
}
7878
}
79-
return fmt.Errorf("RAM resource share invitation found, should be destroyed")
79+
80+
return nil
8081
}
8182

8283
func testAccCheckAwsRamResourceShareAccepterExists(name string) resource.TestCheckFunc {

website/aws.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,6 @@
324324
</li>
325325
</ul>
326326
</li>
327-
<li>
328-
<a href="/docs/providers/aws/r/ram_resource_share_accepter.html">aws_ram_resource_share_accepter</a>
329-
</li>
330327
</ul>
331328
</li>
332329
<li>
@@ -2280,6 +2277,9 @@
22802277
<li>
22812278
<a href="/docs/providers/aws/r/ram_resource_share.html">aws_ram_resource_share</a>
22822279
</li>
2280+
<li>
2281+
<a href="/docs/providers/aws/r/ram_resource_share_accepter.html">aws_ram_resource_share_accepter</a>
2282+
</li>
22832283
</ul>
22842284
</li>
22852285
</ul>

website/docs/r/ram_principal_association.markdown

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,17 @@ description: |-
88

99
# Resource: aws_ram_principal_association
1010

11-
Provides a Resource Access Manager (RAM) principal association.
11+
Provides a Resource Access Manager (RAM) principal association. Depending if [RAM Sharing with AWS Organizations is enabled](https://docs.aws.amazon.com/ram/latest/userguide/getting-started-sharing.html#getting-started-sharing-orgs), the RAM behavior with different principal types changes.
1212

13-
~> *NOTE:* For an AWS Account ID principal, the target account must accept the RAM association invitation after resource creation.
13+
When RAM Sharing with AWS Organizations is enabled:
14+
15+
- For AWS Account ID, Organization, and Organizational Unit principals within the same AWS Organization, no resource share invitation is sent and resources become available automatically after creating the association.
16+
- For AWS Account ID principals outside the AWS Organization, a resource share invitation is sent and must be accepted before resources become available. See the [`aws_ram_resource_share_accepter` resource](/docs/providers/aws/r/ram_resource_share_accepter.html) to accept these invitations.
17+
18+
When RAM Sharing with AWS Organizations is not enabled:
19+
20+
- Organization and Organizational Unit principals cannot be used.
21+
- For AWS Account ID principals, a resource share invitation is sent and must be accepted before resources become available. See the [`aws_ram_resource_share_accepter` resource](/docs/providers/aws/r/ram_resource_share_accepter.html) to accept these invitations.
1422

1523
## Example Usage
1624

website/docs/r/ram_resource_share_accepter.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ description: |-
1010

1111
Manage accepting a Resource Access Manager (RAM) Resource Share invitation. From a _receiver_ AWS account, accept an invitation to share resources that were shared by a _sender_ AWS account. To create a resource share in the _sender_, see the [`aws_ram_resource_share` resource](/docs/providers/aws/r/ram_resource_share.html).
1212

13-
~> **Note:** You can [`share resources`](https://docs.aws.amazon.com/ram/latest/userguide/getting-started-sharing.html) with Organizations, Organizational Units (OUs), AWS accounts, and accounts from outside of your Organization.
13+
~> **Note:** If both AWS accounts are in the same Organization and [RAM Sharing with AWS Organizations is enabled](https://docs.aws.amazon.com/ram/latest/userguide/getting-started-sharing.html#getting-started-sharing-orgs), this resource is not necessary as RAM Resource Share invitations are not used.
1414

1515
## Example Usage
1616

0 commit comments

Comments
 (0)