

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# 関数
<a name="ebextensions-functions"></a>

設定ファイル内の関数を使用して、別のリソースまたは Elastic Beanstalk 設定オプションの設定からの情報で、リソースプロパティの値を入力できます。Elastic Beanstalk は CloudFormation 、関数 (`Ref`、`Fn::GetAtt`、`Fn::Join`) と 1 つの Elastic Beanstalk 固有の関数 をサポートしています`Fn::GetOptionSetting`。

**Topics**
+ [参照番号](#ebextensions-functions-ref)
+ [Fn::GetAtt](#ebextensions-functions-getatt)
+ [Fn::Join](#ebextensions-functions-join)
+ [Fn::GetOptionSetting](#ebextensions-functions-getoptionsetting)

## 参照番号
<a name="ebextensions-functions-ref"></a>

を使用して`Ref`、 AWS リソースのデフォルトの文字列表現を取得します。`Ref` によって返される値は、リソースタイプによって異なりますが、他の要因によって異なる場合もあります。たとえば、セキュリティグループ ([AWS::EC2::SecurityGroup](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group.html)) は、セキュリティグループがデフォルト [Amazon Virtual Private Cloud](https://docs.aws.amazon.com/vpc/latest/userguide/) (Amazon VPC)、EC2 Classic、カスタム VPC 内のいずれにあるかに応じて、セキュリティグループの名前または ID を返します。

```
{ "Ref" : "resource name" }
```

**注記**  
`Ref` の戻り値を含む各リソースタイプの詳細については、[AWS ユーザーガイド](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html)の、*CloudFormation リソースプロパティタイプのリファレンス*を参照してください。

サンプルの [Auto Scaling のライフサイクルフックから](environment-resources.md):

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

`Ref` を使用して、同じファイルまたは別の設定ファイルの他の場所で定義された CloudFormation パラメータの値を取得することもできます。

## Fn::GetAtt
<a name="ebextensions-functions-getatt"></a>

`Fn::GetAtt` を使用して、 AWS リソースの 属性の値を取得します。

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

サンプルの [Auto Scaling のライフサイクルフックから](environment-resources.md):

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

詳細については、「[Fn::GetAtt](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html)」を参照してください。

## Fn::Join
<a name="ebextensions-functions-join"></a>

`Fn::Join` を使用して、区切り文字の文字列を結合します。文字列はハードコード化したり、`Fn::GetAtt` または `Ref` の出力を使用できます。

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

詳細については、「[Fn::Join](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-join.html)」を参照してください。

## Fn::GetOptionSetting
<a name="ebextensions-functions-getoptionsetting"></a>

`Fn::GetOptionSetting` を使用して、環境に適用する[設定オプション](command-options.md)の設定の値を取得します。

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

[プライベートキーを保存](https-storingprivatekeys.md)からの例

```
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"
```