Ref
The intrinsic function Ref returns the value of the specified
parameter or resource.
-
When you specify a parameter's logical name, it returns the value of the parameter.
-
When you specify a resource's logical name, it returns a value that you can typically use to refer to that resource, such as a physical ID.
When you are declaring a resource in a template and you need to specify another template
resource by name, you can use the Ref to refer to that other resource. In
general, Ref returns the name of the resource. For example, a reference to an
AWS::AutoScaling::AutoScalingGroup returns
the name of that Auto Scaling group resource.
For some resources, an identifier is returned that has another significant meaning in the context of the resource. An AWS::EC2::EIP resource, for instance, returns the IP address, and an AWS::EC2::Instance returns the instance ID.
At the bottom of this topic, there is a table that lists the values returned for many
common resource types. More information about Ref return values for a particular
resource or property can be found in the documentation for that resource or property.
Tip
You can also use Ref to add values to Output messages.
Declaration
JSON
{ "Ref" : "logicalName" }
YAML
Syntax for the full function name:
Ref:logicalName
Syntax for the short form:
!ReflogicalName
Parameters
- logicalName
-
The logical name of the resource or parameter you want to dereference.
Return Value
The physical ID of the resource or the value of the parameter.
Example
The following resource declaration for an Elastic IP address needs the instance ID
of an
EC2 instance and uses the Ref function to specify the instance ID of the
MyEC2Instance resource:
JSON
"MyEIP" : { "Type" : "AWS::EC2::EIP", "Properties" : { "InstanceId" : { "Ref" : "MyEC2Instance" } } }
YAML
MyEIP: Type: "AWS::EC2::EIP" Properties: InstanceId: !Ref MyEC2Instance
Supported Functions
You cannot use any functions in the Ref function. You must specify a string
that is a resource logical ID.
Resource Return Examples
This section lists sample values returned by Ref for particular AWS CloudFormation
resources. For more information about Ref return values for a particular
resource or property, refer to the documentation for that resource or property.
| Resource Type | Reference Value | Example Return Value |
|---|---|---|
| Alexa::ASK::Skill | Alexa skill ID | amzn1.ask.skill.a3103cee-c48c-40a0-a2c9-251141888863 |
| AWS::AmazonMQ::Broker | Amazon MQ broker ID | b-1234a5b6-78cd-901e-2fgh-3i45j6k178l9 |
| AWS::AmazonMQ::Configuration | Amazon MQ configuration ID | c-1234a5b6-78cd-901e-2fgh-3i45j6k178l9 |
| AWS::AmazonMQ::ConfigurationAssociation | Amazon MQ configurationassociation ID | c-1234a5b6-78cd-901e-2fgh-3i45j6k178l9 |
|
API Gateway account resource ID |
|
|
|
API key |
|
|
|
Authorizer resource ID |
|
|
|
Client certificate name |
|
|
|
Deployment resource ID |
|
|
|
Documentation part ID |
|
|
|
Domain name |
|
|
|
Method resource ID |
|
|
|
Model name |
|
|
|
Request validator ID |
|
|
|
API Gateway resource ID |
|
|
|
Rest API resource ID |
|
|
|
Stage name |
|
|
|
VPC link ID |
|
|
|
API resource ID |
|
|
|
API mapping resource ID |
|
|
|
Authorizer resource ID |
|
|
|
Deployment resource ID |
|
|
|
Domain name |
|
|
|
Integration resource ID |
|
|
|
Integration response resource ID |
|
|
|
Model resource ID |
|
|
|
Route resource ID |
|
|
|
Route response resource ID |
|
|
|
Stage name |
|
|
| AWS::ApplicationAutoScaling::ScalableTarget |
Scalable Target ID |
|
| AWS::ApplicationAutoScaling::ScalingPolicy |
Application Auto Scaling policy Amazon Resource Name (ARN) |
arn:aws:autoscaling:us-east-1:123456789012:scalingPolicy:12ab3c4d-56789-0ef1-2345-6ghi7jk8lm90:resource/ecs/service/ecsStack-MyECSCluster-AB12CDE3F4GH/ecsStack-MyECSService-AB12CDE3F4GH:policyName/MyStepPolicy |
| AWS::AppMesh::Mesh | Mesh ARN | arn:aws:appmesh:us-east-1:555555555555:mesh/myMesh |
| AWS::AppMesh::Route | Route ARN | arn:aws:appmesh:us-east-1:555555555555:route/myRoute |
| AWS::AppMesh::VirtualNode | Virtual node ARN | arn:aws:appmesh:us-east-1:555555555555:virtualNode/myVirtualNode |
| AWS::AppMesh::VirtualRouter | Virtual router ARN | arn:aws:appmesh:us-east-1:555555555555:virtualRouter/myVirtualRouter |
| AWS::AppMesh::VirtualService | Virtual service ARN | arn:aws:appmesh:us-east-1:555555555555:virtualService/myVirtualService |
|
ARN of the API Key |
|
|
|
ARN of the Data Source |
|
|
|
ARN of the FunctionConfiguration |
|
|
|
ARN of the GraphQL API |
|
|
|
GraphQL API id with the literal String GraphQLSchema attached to it |
||
|
ARN of the Resolver |
|
|
|
Named query name |
|
|
|
Amazon Resource Name (ARN) of the scaling plan |
|
|
|
Name |
|
|
|
Name |
|
|
|
Name |
|
|
|
Scaling policy Amazon Resource Name (ARN) |
|
|
|
Name |
|
|
| AWS::Backup::BackupPlan |
|
|
| AWS::Backup::BackupSelection |
|
|
| AWS::Backup::BackupVault |
|
|
| AWS::Batch::ComputeEnvironment |
AWS Batch Compute Environment Amazon Resource Name (ARN) |
|
| AWS::Batch::JobDefinition |
AWS Batch Job Definition Amazon Resource Name (ARN) |
|
| AWS::Batch::JobQueue |
AWS Batch Job Queue Amazon Resource Name (ARN) |
|
| AWS::Budgets::Budget |
Budget name |
|
| AWS::CertificateManager::Certificate |
Certificate Amazon Resource Name (ARN) |
|
|
Development environment ID |
|
|
|
Stack ID |
|
|
|
Name |
|
|
|
Wait Condition Signal URL |
|
|
|
Distribution ID |
|
|
|
Origin access identity |
|
|
|
Streaming distribution ID |
|
|
|
Trail name |
|
|
|
Name |
|
|
|
Name |
||
|
Project name |
|
|
|
Repository ID |
|
|
| AWS::CodeDeploy::Application |
Application name |
|
| AWS::CodeDeploy::DeploymentConfig |
Deployment configuration name |
|
| AWS::CodeDeploy::DeploymentGroup |
Deployment group name |
|
| AWS::CodePipeline::CustomActionType |
Custom action name |
|
| AWS::CodePipeline::Pipeline |
Pipeline name |
|
| AWS::CodePipeline::Webhook |
Webhook name |
|
| AWS::Cognito::IdentityPool |
|
|
| AWS::Cognito::IdentityPoolRoleAttachment |
ID |
|
| AWS::Cognito::UserPool |
ID |
|
| AWS::Cognito::UserPoolClient |
Amazon Cognito user pool client ID |
|
| AWS::Cognito::UserPoolGroup |
Name of the user pool group |
|
| AWS::Cognito::UserPoolUser |
Name of the user |
|
| AWS::Cognito::UserPoolUserToGroupAttachment |
ID |
|
| AWS::Config::AggregationAuthorization |
ARN of the AggregationAuthorization |
|
| AWS::Config::ConfigRule |
Configuration rule name |
|
| AWS::Config::ConfigurationAggregator |
|
|
| AWS::Config::ConfigurationRecorder |
Configuration recorder name |
|
| AWS::Config::DeliveryChannel |
Delivery channel name |
|
| AWS::DataPipeline::Pipeline |
Pipeline ID |
|
|
|
|
|
|
ARN of the created parameter group |
|
|
|
ARN of the created activity |
|
|
| AWS::DirectoryService::MicrosoftAD |
Microsoft directory ID |
|
| AWS::DirectoryService::SimpleAD |
Directory ID |
|
| AWS::DLM::LifecyclePolicy | Policy ID |
|
| AWS::DMS::Certificate |
Amazon Resource Name (ARN) of the certificate |
|
| AWS::DMS::Endpoint |
ARN of the endpoint |
|
| AWS::DMS::EventSubscription |
Event subscription name |
|
| AWS::DMS::ReplicationInstance |
Replication instance ARN |
|
| AWS::DMS::ReplicationSubnetGroup |
Name of the replication subnet group |
|
| AWS::DMS::ReplicationTask |
Replication task ARN |
|
| AWS::DocDB::Cluster |
DB cluster name |
|
| AWS::DocDB::DBClusterParameterGroup |
DB cluster parameter group name |
|
| AWS::DocDB::DBInstance |
DB instance name |
|
| AWS::DocDB::DBSubnetGroup |
DB subnet group name |
|
| AWS::DynamoDB::Table |
Table Name |
|
|
Capacity Reservation ID |
|
|
|
Name |
||
|
Name |
||
|
Fleet ID |
|
|
|
ID of the egress-only Internet gateway |
||
|
Elastic IP Address |
|
|
|
Name |
|
|
|
Flow log ID |
|
|
|
Host ID |
|
|
|
Instance ID |
|
|
|
Name |
||
|
Launch template ID |
|
|
|
NAT gateway ID |
|
|
|
Name |
||
|
Name |
||
|
Name |
||
|
Name |
||
|
Network interface permission ID |
|
|
|
Placement group name |
|
|
|
Name |
||
|
Route table ID |
rtb-12a34567 |
|
|
Name or security group ID (for VPC security groups that are not in a default VPC) |
|
|
|
Name |
|
|
|
Name |
|
|
|
Name |
|
|
|
Subnet ID |
|
|
|
Name |
||
|
Name |
||
|
Transit gateway ID |
|
|
|
Attachment ID |
|
|
|
ID of the route table and destination CIDR, separated by an underscore |
|
|
|
ID of the transit gateway route table |
|
|
|
ID of the attachment and ID of the transit gateway route table, separated by an underscore |
|
|
|
ID of the attachment and ID of the propagation route table, separated by an underscore |
|
|
|
Volume ID |
|
|
|
Name |
|
|
|
VPC ID |
|
|
|
Name |
||
|
Endpoint ID |
|
|
|
ID of the connection notification |
||
|
ID of the VPC endpoint service configuration |
||
|
ID of the VPC endpoint service |
||
|
Name |
||
| AWS::EC2::VPCPeeringConnection |
VPC peering connection ID |
|
|
Name |
||
|
Name |
||
|
Name |
||
|
Name |
||
|
Repository name |
|
|
|
Name |
|
|
|
Service ARN |
|
|
|
Task definition ARN |
|
|
|
File system ID |
|
|
|
Mount target ID |
|
|
|
Cluster name |
|
|
|
Name |
||
|
Name |
||
|
Name |
|
|
|
|
||
|
Name |
|
|
|
Domain name |
|
|
|
Name |
|
|
|
Name |
|
|
|
Name |
|
|
|
Name |
|
|
|
Name |
|
|
|
Listener's Amazon Resource Name (ARN) |
|
|
|
Listener rule's Amazon Resource Name (ARN) |
|
|
|
Application load balancer's Amazon Resource Name (ARN) |
|
|
|
Target group's Amazon Resource Name (ARN) |
|
|
|
Cluster ID |
|
|
|
Instance group ID |
|
|
|
Name |
|
|
|
Step ID |
|
|
|
Event bus policy ID |
|
|
|
Event rule ID |
|
|
|
File system resource ID |
|
|
|
Alias ID |
|
|
|
Build ID |
|
|
|
Fleet ID |
|
|
|
Name |
|
|
|
|
|
|
|
Name |
|
|
|
|
|
|
|
Name |
|
|
|
Name |
||
|
|
|
|
|
Name |
|
|
|
ID |
|
|
|
ARN |
|
|
|
ID |
|
|
|
ARN |
|
|
|
ID |
|
|
|
ARN |
|
|
|
ID |
|
|
|
ARN |
|
|
|
ID |
|
|
|
ARN |
|
|
|
ID |
|
|
|
ARN |
|
|
|
ID |
|
|
|
ARN |
|
|
|
ID |
|
|
|
ARN |
|
|
|
Detector ID |
|
|
|
Name |
|
|
|
IPSet ID |
|
|
|
Master ID |
|
|
|
Member ID |
|
|
|
ThreatIntel Set ID |
|
|
|
AccessKeyId |
|
|
|
Group name |
|
|
|
Name |
||
|
Policy ARN |
|
|
|
Name |
||
|
Name |
|
|
|
User name |
|
|
|
Name |
||
| AWS::IoT::Certificate | Certificate ID | a1234567b89c012d3e4fg567hij8k9l01mno1p23q45678901rs234567890t1u2 |
| AWS::IoT::Policy | Policy name | MyPolicyName |
| AWS::IoT::Thing | Thing name | MyStack-MyThing-AB1CDEFGHIJK |
| AWS::IoT::TopicRule | Topic rule name | MyStackMyTopicRule12ABC3D456EFG |
| AWS::IoT1Click::Device | The device ARN | arn:aws:iot1click:us-west-2:123456789012:devices/G030PX0312744DWM |
| AWS::IoT1Click::Placement | The placement name (associated with a project) | region3 |
| AWS::IoT1Click::Project | The project ARN | arn:aws:iot1click:us-west-2:0123456789012:projects/seattle-region |
|
Name |
|
|
|
Consumer ARN |
|
|
|
Delivery stream name |
|
|
|
Alias name |
|
|
|
Key ID |
|
|
|
Amazon Resource Name of the AWS Lambda alias |
arn:aws:lambda:us-west-2:123456789012:function:helloworld:BETA |
|
|
Name |
|
|
|
Name |
|
|
|
Layer version ARN |
|
|
|
Layer version ARN with statement ID |
|
|
|
Amazon Resource Name of the AWS Lambda version |
arn:aws:lambda:us-west-2:123456789012:function:helloworld:1 |
|
|
Destination name |
|
|
|
Name |
|
|
|
Log stream name |
|
|
|
Subscription filter name |
||
|
Container name |
||
|
Name |
||
|
Name |
||
|
|
|
|
|
Name |
||
|
Name |
|
|
|
AWS OpsWorks Application ID |
|
|
|
AWS OpsWorks Instance ID |
|
|
|
AWS OpsWorks Layer ID |
|
|
|
AWS OpsWorks Stack ID |
|
|
|
IAM user Amazon Resource Name |
|
|
|
AWS OpsWorks Volume ID |
|
|
|
AWS OpsWorks CM server Amazon Resource Name |
|
|
|
The name of an Amazon Pinpoint Email API configuration set |
|
|
|
The name of an event destination in an Amazon Pinpoint Email API configuration set |
|
|
|
The name of a dedicated IP pool used to send email through the Amazon Pinpoint Email API |
|
|
|
The name (email address or domain name) of an identity used to send email by using the Amazon Pinpoint Email API. |
|
|
|
Resource share ARN |
|
|
|
Cluster name |
|
|
|
Parameter group name |
|
|
|
Name |
|
|
|
Name |
||
|
Name |
|
|
|
Name |
||
|
DB subnet group name |
|
|
|
Name |
|
|
|
Name |
|
|
|
Name |
|
|
|
Name |
|
|
|
Name |
|
|
|
Name |
|
|
| Amazon Resource Name (ARN) of the fleet |
|
|
|
Amazon Resource Name (ARN) of the robot |
|
|
|
Amazon Resource Name (ARN) of the robot application |
|
|
|
Amazon Resource Name (ARN) of the robot application version |
|
|
|
Amazon Resource Name (ARN) of the simulation application |
|
|
|
Amazon Resource Name (ARN) of the simulation application version |
|
|
|
Amazon Route 53 health check ID |
|
|
| Hosted zone ID |
|
|
|
Name |
||
|
Name |
||
| Endpoint ID |
|
|
| Rule ID |
|
|
| Resolver rule association ID |
|
|
|
Name |
|
|
|
Amazon Resource Name (ARN) of the endpoint |
|
|
|
Amazon Resource Name (ARN) of the endpoint configuration |
|
|
|
Amazon Resource Name (ARN) of the model |
|
|
|
Amazon Resource Name (ARN) of the notebook instance |
|
|
|
Amazon Resource Name (ARN) of the lifecycle configuration |
|
|
|
ARN of the secret |
|
|
|
ARN of the secret |
|
|
| AWS::SecretsManager::Secret | Secret ARN | arn:aws:secretsmanager:us-east-2:123456789012:secret:MyPath/MySecretName-a1b2c3 |
|
Secret ARN |
|
|
|
Id |
||
|
Provisioning artifact ID |
|
|
|
Provisioned product ID |
|
|
|
Constraint ID |
||
|
Constraint ID |
||
|
Constraint ID |
||
|
Portfolio ID |
||
|
Association ID |
||
|
Association ID |
||
|
Portfolio share ID |
||
|
Constraint ID |
||
|
Tag option ID |
||
|
Association ID |
||
|
Id |
|
|
|
|
||
|
|
||
|
|
||
|
|
||
|
Name |
||
|
Name |
|
|
|
Name |
|
|
|
Name |
|
|
|
Topic ARN |
|
|
|
Queue URL |
|
|
|
SSM document name |
|
|
|
Maintenance window ID |
|
|
|
Maintenance window target ID |
|
|
|
Maintenance window task ID |
|
|
|
Patch baseline ID |
The ID of the default patch baseline provided by AWS is an ARN—for
example
|
|
|
Name |
|
|
| AWS::StepFunctions::Activity | Amazon Resource Name (ARN) of the AWS Step Functions activity | arn:aws:states:us-east-1:111122223333:activity:myActivity |
| AWS::StepFunctions::StateMachine | ARN of the created Step Functions state machine | arn:aws:states:us-east-1:111122223333:stateMachine:MyStateMachine-ABCDEFGHIJ1K |
|
Byte match ID |
|
|
|
IP set ID |
|
|
|
Rule ID |
|
|
|
Size constraint set ID |
|
|
|
SQL match set ID |
|
|
|
Web ACL ID |
|
|
|
XSS match set ID |
|
|
|
Byte match ID |
|
|
|
IP set ID |
|
|
|
Rule ID |
|
|
|
Size constraint set ID |
|
|
|
SQL match set ID |
|
|
|
Web ACL ID |
|
|
|
XSS match set ID |
|
|
|
Workspace ID |
|
|
|
AWS::AccountId |
|
|
|
AWS::NotificationARNs |
|
|
|
AWS::NoValue |
Does not return a value. |
|
|
AWS::Partition |
|
|
|
AWS::Region |
|
|
|
AWS::StackId |
|
|
|
AWS::StackName |
|
|
|
AWS::URLSuffix |
|


