AWS CloudFormation
User Guide (API Version 2010-05-15)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.Did this page help you?  Yes | No |  Tell us about it...

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.

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

"Ref" : "logicalName"

Parameters

logicalName

The logical name of the resource or parameter you want to dereference.

Return Value

The value of the MyInputParameter 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:

"MyEIP" : {
   "Type" : "AWS::EC2::EIP",
   "Properties" : {
      "InstanceId" : { "Ref" : "MyEC2Instance" }
   }
}     

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 TypeReference ValueExample

AWS::AutoScaling::AutoScalingGroup

Name

mystack-myasgroup-NT5EUXTNTXXD

AWS::AutoScaling::LaunchConfiguration

Name

mystack-mylaunchconfig-1DDYF1E3B3I

AWS::AutoScaling::ScalingPolicy

Name

mystack-myaspolicy-1DDYF1E3B3I

AWS::AutoScaling::Trigger

Name

mystack-mytrigger-7GQPDS5YHI5B

AWS::CloudFormation::Stack

Stack ID

arn:aws:cloudformation:us-east-1:803981987763:stack/mystack-myembeddedstack-sggfrhxhum7w/f449b250-b969-11e0-a185-5081d0136786

AWS::CloudFormation::WaitCondition

Name

arn:aws:cloudformation:us-east-1:803981987763:stack/mystack/c325e210-bdf2-11e0-9638-50690880c386/mywaithandle

AWS::CloudFormation::WaitConditionHandle

Wait Condition Signal URL

https://cloudformation-waitcondition-us-east-1.s3.amazonaws.com/arn%3Aaws%3Acloudformation%3Aus-east-1%3A803981987763%3Astack%2Fwaittest%2F054a33d0-bdee-11e0-8816-5081c490a786%2FmyWaitHandle?Expires=1312475488&AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE&Signature=tUsrW3WvWVT46K69zMmgbEkwVGo%3D

AWS::CloudFront::Distribution

Distribution ID

E27LVI50CSW06W

AWS::CloudWatch::Alarm

Name

mystack-myalarm-3AOHFRGOXR5T

AWS::EC2::Volume

Volume ID

vol-3cdd3f56

AWS::EC2::VolumeAttachment

Name

mystack-myvola-ERXHJITXMRLT

AWS::EC2::EIP

Elastic IP Address

192.0.2.0

AWS::EC2::EIPAssociation

Name

mystack-myeipa-1NU3IL8LJ313N

AWS::EC2::Instance

Instance ID

i-636be302

AWS::EC2::SecurityGroup

Name

mystack-mysecuritygroup-QQB406M8FISX

AWS::EC2::SecurityGroupIngress

Name

mysecuritygroupingress

AWS::ElasticLoadBalancing::LoadBalancer

Name

mystack-myelb-1WQN7BJGDB5YQ

AWS::ElasticBeanstalk::Application

Name

mystack-myapplication-FM6BIXY7U8PK

AWS::ElasticBeanstalk::Environment

Name

mystack-myenv-LKGNQSFHO1DB

AWS::IAM::AccessKey

AccessKeyId

AKIAIOSFODNN7EXAMPLE

AWS::IAM::Group

GroupName

mystack-mygroup-1DZETITOWEKVO

AWS::IAM::User

UserName

mystack-myuser-1CCXAFG2H2U4D

AWS::RDS::DBInstance

Name

mystack-mydb-ea5ugmfvuaxg

AWS::RDS::DBSecurityGroup

Name

mystack-mydbsecuritygroup-1k5u5dxjb0nxs

AWS::S3::Bucket

Name

mystack-mys3bucket-1hbsmonr9mytq

AWS::SDB::Domain

Name

mystack-mysdbdomain-IVNAOZTDFVXL

AWS::SNS::Topic

Topic ARN

arn:aws:sns:us-east-1:803981987763:mystack-mytopic-NZJ5JSMVGFIE

AWS::SQS::Queue

Queue URL

https://sqs.us-east-1.amazonaws.com/803981987763/aa4-MyQueue-Z5NOSZO2PZE9

Pseudo Parameter

AWS::Region

us-east-1

Pseudo Parameter

AWS::StackName

MyStack