

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

# AWS::Serverless::LayerVersion
<a name="sam-resource-layerversion"></a>

Lambda 関数に必要なライブラリまたはランタイムコードが含まれる Lambda LayerVersion を作成します。

[AWS::Serverless::LayerVersion](#sam-resource-layerversion) リソースは `Metadata`リソース属性もサポートしているため、アプリケーションに含まれるレイヤーを構築する AWS SAM ように に指示できます。レイヤーの構築に関する詳細については、「[での Lambda レイヤーの構築 AWS SAM](building-layers.md)」を参照してください。

**重要な注意**: で [UpdateReplacePolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatereplacepolicy.html) リソース属性がリリースされたため CloudFormation、 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html) (推奨) には と同じ利点があります[AWS::Serverless::LayerVersion](#sam-resource-layerversion)。

サーバーレス LayerVersion が変換されると、SAM はリソースの論理 ID も変換し、リソースの更新時に CloudFormation によって古い LayerVersion が自動的に削除されないようにします。

**注記**  
にデプロイすると AWS CloudFormation、 は AWS SAM リソースを CloudFormation リソース AWS SAM に変換します。詳細については、「[の生成済み CloudFormation リソース AWS SAM](sam-specification-generated-resources.md)」を参照してください。

## 構文
<a name="sam-resource-layerversion-syntax"></a>

 AWS Serverless Application Model (AWS SAM) テンプレートでこのエンティティを宣言するには、次の構文を使用します。

### YAML
<a name="sam-resource-layerversion-syntax.yaml"></a>

```
Type: AWS::Serverless::LayerVersion
Properties:
  [CompatibleArchitectures](#sam-layerversion-compatiblearchitectures): List
  [CompatibleRuntimes](#sam-layerversion-compatibleruntimes): List
  [ContentUri](#sam-layerversion-contenturi): String | LayerContent
  [Description](#sam-layerversion-description): String
  [LayerName](#sam-layerversion-layername): String
  [LicenseInfo](#sam-layerversion-licenseinfo): String
  [PublishLambdaVersion](#sam-layerversion-PublishLambdaVersion): Boolean
  [RetentionPolicy](#sam-layerversion-retentionpolicy): String
```

## プロパティ
<a name="sam-resource-layerversion-properties"></a>

 `CompatibleArchitectures`   <a name="sam-layerversion-compatiblearchitectures"></a>
レイヤバージョンでサポートされる命令セットアーキテクチャを指定します。  
このプロパティの詳細については、*AWS Lambda デベロッパーガイド*の「[Lambda 命令セットアーキテクチャ](https://docs.aws.amazon.com/lambda/latest/dg/foundation-arch.html)」を参照してください。  
*有効な値*: `x86_64`、`arm64`  
*タイプ*: リスト  
*必須:* いいえ  
*デフォルト*: `x86_64`  
*CloudFormation 互換性*: このプロパティは、 `AWS::Lambda::LayerVersion`リソースの `[CompatibleArchitectures](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html#cfn-lambda-layerversion-compatiblearchitectures)`プロパティに直接渡されます。

 `CompatibleRuntimes`   <a name="sam-layerversion-compatibleruntimes"></a>
この LayerVersion との互換性のあるランタイムのリストです。  
*タイプ*: リスト  
*必須:* いいえ  
*CloudFormation 互換性*: このプロパティは、 `AWS::Lambda::LayerVersion`リソースの `[CompatibleRuntimes](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html#cfn-lambda-layerversion-compatibleruntimes)`プロパティに直接渡されます。

 `ContentUri`   <a name="sam-layerversion-contenturi"></a>
Amazon S3 URI、ローカルフォルダーへのパス、またはレイヤーコードの LayerContent オブジェクトです。  
Amazon S3 URI または LayerContent オブジェクトが提供されている場合、参照される Amazon S3 オブジェクトは、[Lambda レイヤー](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html)のコンテンツが含まれる有効な ZIP アーカイブである必要があります。  
ローカルフォルダへのパスが提供されている場合は、コンテンツが適切に変換されるようにするために、[sam build](sam-cli-command-reference-sam-build.md) が含まれ、その後に [sam deploy](sam-cli-command-reference-sam-deploy.md) または [sam package](sam-cli-command-reference-sam-package.md) が続くワークフローをテンプレートが実行する必要があります。デフォルトでは、相対パスは AWS SAM テンプレートの場所に関して解決されます。  
*タイプ*: 文字列 \$1 [LayerContent](sam-property-layerversion-layercontent.md)  
*必須:* はい  
*CloudFormation 互換性*: このプロパティは、 `AWS::Lambda::LayerVersion`リソースの `[Content](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html#cfn-lambda-layerversion-content)`プロパティに似ています。ネストされた Amazon S3 プロパティには異なる名前が付けられています。

 `Description`   <a name="sam-layerversion-description"></a>
このレイヤーの説明です。  
*タイプ*: 文字列  
*必須:* いいえ  
*CloudFormation 互換性*: このプロパティは、 `AWS::Lambda::LayerVersion`リソースの `[Description](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html#cfn-lambda-layerversion-description)`プロパティに直接渡されます。

 `LayerName`   <a name="sam-layerversion-layername"></a>
レイヤーの名前または Amazon リソースネーム (ARN) です。  
*タイプ*: 文字列  
*必須:* いいえ  
*デフォルト*: リソースの論理 ID  
*CloudFormation 互換性*: このプロパティは、 `AWS::Lambda::LayerVersion`リソースの `[LayerName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html#cfn-lambda-layerversion-layername)`プロパティに似ています。名前を指定しない場合は、リソースの論理 ID が名前として使用されます。

 `LicenseInfo`   <a name="sam-layerversion-licenseinfo"></a>
この LayerVersion のライセンスに関する情報です。  
*タイプ*: 文字列  
*必須:* いいえ  
*CloudFormation 互換性*: このプロパティは、 `AWS::Lambda::LayerVersion`リソースの `[LicenseInfo](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html#cfn-lambda-layerversion-licenseinfo)`プロパティに直接渡されます。

 `PublishLambdaVersion`   <a name="sam-layerversion-PublishLambdaVersion"></a>
参照される `LayerVersion` リソースに変更があるたびに新しい Lambda バージョンを作成するオプトインプロパティ。接続された Lambda 関数 で `AutoPublishAlias` と `AutoPublishAliasAllProperties` を使用して有効にすると、`LayerVersion` リソースに行われる変更ごとに新しい Lambda バージョンが作成されます。  
型: ブール  
*必須:* いいえ  
*CloudFormation 互換性*: このプロパティは に固有 AWS SAM であり、 CloudFormation 同等のものはありません。

 `RetentionPolicy`   <a name="sam-layerversion-retentionpolicy"></a>
このプロパティは、リソースを削除するときに `LayerVersion` の古いバージョンを保持するか削除するかを指定します。リソースを更新または置き換えるときに `LayerVersion` の古いバージョンを保持する必要がある場合は、 `UpdateReplacePolicy` 属性を有効にする必要があります。これを行う方法については、「*AWS CloudFormation ユーザーガイド*」の 「[`UpdateReplacePolicy` 属性](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatereplacepolicy.html)」を参照してください。  
*有効な値*: `Retain` または `Delete`  
タイプ：文字列  
*必須:* いいえ  
*CloudFormation 互換性*: このプロパティは に固有 AWS SAM であり、 CloudFormation 同等のものはありません。  
*追加の注意*: を指定すると`Retain`、 は変換された`AWS::Lambda::LayerVersion`リソース`DeletionPolicy: Retain`に [でサポートされるリソース属性 AWS SAM](sam-specification-resource-attributes.md) の AWS SAM を追加します。

## 戻り値
<a name="sam-resource-layerversion-return-values"></a>

### 参照番号
<a name="sam-resource-layerversion-return-values-ref"></a>

このリソースの論理 ID が `Ref` 組み込み関数に提供されると、基盤となる Lambda LayerVersion のリソース ARN が返されます。

`Ref` 関数の使用方法の詳細については、*AWS CloudFormation ユーザーガイド*の「[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)」を参照してください。

## 例
<a name="sam-resource-layerversion--examples"></a>

### LayerVersionExample
<a name="sam-resource-layerversion--examples--layerversionexample"></a>

LayerVersion の例

#### YAML
<a name="sam-resource-layerversion--examples--layerversionexample--yaml"></a>

```
Properties:
  LayerName: MyLayer
  Description: Layer description
  ContentUri: 's3://sam-s3-demo-bucket/my-layer.zip'
  CompatibleRuntimes:
    - nodejs10.x
    - nodejs12.x
  LicenseInfo: 'Available under the MIT-0 license.'
  RetentionPolicy: Retain
```

# LayerContent
<a name="sam-property-layerversion-layercontent"></a>

[Lambda レイヤー](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html)のコンテンツが含まれる ZIP アーカイブです。

## 構文
<a name="sam-property-layerversion-layercontent-syntax"></a>

 AWS Serverless Application Model (AWS SAM) テンプレートでこのエンティティを宣言するには、次の構文を使用します。

### YAML
<a name="sam-property-layerversion-layercontent-syntax.yaml"></a>

```
  [Bucket](#sam-layerversion-layercontent-bucket): String
  [Key](#sam-layerversion-layercontent-key): String
  [Version](#sam-layerversion-layercontent-version): String
```

## プロパティ
<a name="sam-property-layerversion-layercontent-properties"></a>

 `Bucket`   <a name="sam-layerversion-layercontent-bucket"></a>
レイヤーアーカイブの Amazon S3 バケットです。  
*タイプ*: 文字列  
*必須*: はい  
*CloudFormation 互換性*: このプロパティは、 `AWS::Lambda::LayerVersion` `Content` データ型の `[S3Bucket](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-layerversion-content.html#cfn-lambda-layerversion-content-s3bucket)`プロパティに直接渡されます。

 `Key`   <a name="sam-layerversion-layercontent-key"></a>
レイヤーアーカイブの Amazon S3 キーです。  
*タイプ*: 文字列  
*必須*: はい  
*CloudFormation 互換性*: このプロパティは、 `AWS::Lambda::LayerVersion` `Content` データ型の `[S3Key](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-layerversion-content.html#cfn-lambda-layerversion-content-s3key)`プロパティに直接渡されます。

 `Version`   <a name="sam-layerversion-layercontent-version"></a>
バージョン管理されたオブジェクトの場合に使用する、レイヤーアーカイブオブジェクトのバージョンです。  
*タイプ*: 文字列  
*必須:* いいえ  
*CloudFormation 互換性*: このプロパティは、 `AWS::Lambda::LayerVersion` `Content` データ型の `[S3ObjectVersion](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-layerversion-content.html#cfn-lambda-layerversion-content-s3objectversion)`プロパティに直接渡されます。

## 例
<a name="sam-property-layerversion-layercontent--examples"></a>

### LayerContent
<a name="sam-property-layerversion-layercontent--examples--layercontent"></a>

LayerContent の例

#### YAML
<a name="sam-property-layerversion-layercontent--examples--layercontent--yaml"></a>

```
LayerContent:
  Bucket: amzn-s3-demo-bucket-name
  Key: mykey-name
  Version: 121212
```