AWS RAM Resource Association
This page shows how to write Terraform and CloudFormation for AWS RAM Resource Association and write them securely.
aws_ram_resource_association (Terraform)
The Resource Association in AWS RAM can be configured in Terraform with the resource name aws_ram_resource_association
. The following sections describe 5 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_ram_resource_association" "ram-prod-priv-1x" {
resource_arn = aws_subnet.privsubnet-1.arn
resource_share_arn = aws_ram_resource_share.rams-prod-1x.arn
}
resource "aws_ram_resource_association" "ram-prod-priv-1y" {
resource "aws_ram_resource_association" "transit-gateway" {
resource_arn = aws_ec2_transit_gateway.transit-gateway.arn
resource_share_arn = aws_ram_resource_share.transit-gateway.id
}
# Create a resource share for the Certificate Manager
resource "aws_ram_resource_association" "internet" {
resource_share_arn = aws_ram_resource_share.internet.arn
resource_arn = aws_ec2_transit_gateway.internet.arn
}
resource "aws_ram_principal_association" "internet" {
resource "aws_ram_resource_association" "internal_rule" {
count = var.is_hub ? 1 : 0
resource_arn = aws_route53_resolver_rule.forward_internal[0]
resource_share_arn = aws_ram_resource_share.dns[0]
}
resource "aws_ram_resource_association" "$instance.getAttribute("association_name")" {
resource_arn = $instance.getAttribute("resource_arn")
resource_share_arn = $instance.getAttribute("resource_share_arn")
Parameters
-
id
optional computed - string -
resource_arn
required - string -
resource_share_arn
required - string
Explanation in Terraform Registry
Manages a Resource Access Manager (RAM) Resource Association.
NOTE: Certain AWS resources (e.g., EC2 Subnets) can only be shared in an AWS account that is a member of an AWS Organizations organization with organization-wide Resource Access Manager functionality enabled. See the Resource Access Manager User Guide and AWS service specific documentation for additional information.
AWS::RAM::ResourceShare (CloudFormation)
The ResourceShare in RAM can be configured in CloudFormation with the resource name AWS::RAM::ResourceShare
. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
Type: AWS::RAM::ResourceShare
DependsOn: TransitGateway
Properties:
AllowExternalPrincipals: false
Name: "Transit Gateway Resource Share"
ResourceArns:
Type: AWS::RAM::ResourceShare
Properties:
AllowExternalPrincipals: false
Name: !Sub ${RootStackName}_shared
Principals: !Ref SharedResourceSharePrincipals
ResourceArns:
Type: AWS::RAM::ResourceShare
Properties:
AllowExternalPrincipals: true
Name: mesh-share
Principals:
- !Ref ConsumerAccountId
Type: AWS::RAM::ResourceShare
Properties:
AllowExternalPrincipals: true
Name: mesh-share
Principals:
- !Ref ConsumerAccountId
Type: AWS::RAM::ResourceShare
Properties:
AllowExternalPrincipals: true
Name: mesh-share
Principals:
- !Ref ConsumerAccountId
"Type": "AWS::RAM::ResourceShare",
"Properties": {
"Name": {
"Ref": "ResourceShareName"
},
"AllowExternalPrincipals": false,
"Type": "AWS::RAM::ResourceShare",
"Properties": {
"Name": {
"Ref": "ResourceShareName"
},
"AllowExternalPrincipals": false,
"AWS::RAM::ResourceShare": {
"Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ram-resourceshare.html",
"Attributes": {
"Arn": {
"PrimitiveType": "String"
}
"AWS::RAM::ResourceShare": {
"Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ram-resourceshare.html",
"Attributes": {
"Arn": {
"PrimitiveType": "String"
}
"AWS::RAM::ResourceShare": {
"Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ram-resourceshare.html",
"Attributes": {
"Arn": {
"PrimitiveType": "String"
}
Parameters
-
PermissionArns
optional - List -
Principals
optional - List -
AllowExternalPrincipals
optional - Boolean -
ResourceArns
optional - List -
Tags
optional - List of Tag -
Name
required - String
Explanation in CloudFormation Registry
Specifies a resource share.
Frequently asked questions
What is AWS RAM Resource Association?
AWS RAM Resource Association is a resource for RAM of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.
Where can I find the example code for the AWS RAM Resource Association?
For Terraform, the trilogy-group/CENPRO-24625, ministryofjustice/modernisation-platform and cicdenv/cicdenv source code examples are useful. See the Terraform Example section for further details.
For CloudFormation, the deiselira/aws, PRX/Infrastructure and ft20006/aws-app-mesh-examples source code examples are useful. See the CloudFormation Example section for further details.