View a markdown version of this page

Functions - AWS Elastic Beanstalk

Functions

You can use functions in your configuration files to populate values for resource properties with information from other resources or from Elastic Beanstalk configuration option settings. Elastic Beanstalk supports CloudFormation functions (Ref, Fn::GetAtt, Fn::Join), and one Elastic Beanstalk-specific function, Fn::GetOptionSetting.

Ref

Use Ref to retrieve the default string representation of an AWS resource. The value returned by Ref depends on the resource type, and sometimes depends on other factors as well. For example, a security group (AWS::EC2::SecurityGroup) returns either the name or ID of the security group, depending on if the security group is in a default Amazon Virtual Private Cloud (Amazon VPC), EC2 classic, or a custom VPC.

{ "Ref" : "resource name" }
Note

For details on each resource type, including the return value(s) of Ref, see AWS Resource Types Reference in the CloudFormation User Guide.

From the sample Auto Scaling lifecycle hook:

Resources:
 lifecyclehook:
 Type: AWS::AutoScaling::LifecycleHook
 Properties:
 AutoScalingGroupName: { "Ref" : "AWSEBAutoScalingGroup" }

You can also use Ref to retrieve the value of a CloudFormation parameter defined elsewhere in the same file or in a different configuration file.

Fn::GetAtt

Use Fn::GetAtt to retrieve the value of an attribute on an AWS resource.

{ "Fn::GetAtt" : [ "resource name", "attribute name"] }

From the sample Auto Scaling lifecycle hook:

Resources:
 lifecyclehook:
 Type: AWS::AutoScaling::LifecycleHook
 Properties:
 RoleARN: { "Fn::GetAtt" : [ "hookrole", "Arn"] }

See Fn::GetAtt for more information.

Fn::Join

Use Fn::Join to combine strings with a delimiter. The strings can be hard-coded or use the output from Fn::GetAtt or Ref.

{ "Fn::Join" : [ "delimiter", [ "string1", "string2" ] ] }

See Fn::Join for more information.

Fn::GetOptionSetting

Use Fn::GetOptionSetting to retrieve the value of a configuration option setting applied to the environment.

"Fn::GetOptionSetting":
 Namespace: "namespace"
 OptionName: "option name"
 DefaultValue: "default value"

From the storing private keys example:

Resources:
 AWSEBAutoScalingGroup:
 Metadata:
 AWS::CloudFormation::Authentication:
 S3Auth:
 type: "s3"
 buckets: ["elasticbeanstalk-us-west-2-123456789012"]
 roleName: 
 "Fn::GetOptionSetting": 
 Namespace: "aws:autoscaling:launchconfiguration"
 OptionName: "IamInstanceProfile"
 DefaultValue: "aws-elasticbeanstalk-ec2-role"

Warning Javascript is disabled or is unavailable in your browser.

To use the Amazon Web Services Documentation, Javascript must be enabled. Please refer to your browser's Help pages for instructions.

Did this page help you? - Yes

Thanks for letting us know we're doing a good job!

If you've got a moment, please tell us what we did right so we can do more of it.

Did this page help you? - No

Thanks for letting us know this page needs work. We're sorry we let you down.

If you've got a moment, please tell us how we can make the documentation better.

AltStyle によって変換されたページ (->オリジナル) /