#
ドキュメント

Document

自分のための備忘録です。

変更セット(置換 Replacement )

おもに Action が Modify の Replacement ( True | False | Conditional )について記載しています。

ドキュメント

変更セットフィールド サンプル

 "Changes": [
        {
            "ResourceChange": {
                "ResourceType": "AWS::EC2::Instance",
                "PhysicalResourceId": "i-1abc23d4",
                "Details": [
                    {
                        "ChangeSource": "DirectModification",
                        "Evaluation": "Static",
                        "Target": {
                            "Attribute": "Tags",
                            "RequiresRecreation": "Never"
                        }
                    }
                ],
                "Action": "Modify",
                "Scope": [
                    "Tags"
                ],
                "LogicalResourceId": "MyEC2Instance",
                "Replacement": "False"
            },
            "Type": "Resource"
        }
    ],

変更セットの各フィールドの説明については、「AWS CloudFormation API リファレンス」の「変更データ型」を参照してください。

ref. 変更セットのサンプル

Change

  • Changes.HookInvocationCount
  • Changes.ResourceChange

    A ResourceChange structure that describes the resource and action that CloudFormation will perform.

  • Changes.Type

    The type of entity that CloudFormation changes.

ResourceChange

Changes.ResourceChange.Action

Action The action that CloudFormation takes on the resource, such as Add (adds a new resource), Modify (changes a resource), Remove (deletes a resource), Import (imports a resource), or > Dynamic (exact action for the resource can't be determined).

Type: String

Valid Values: Add | Modify | Remove | Import | Dynamic

Required: No

ref. ResourceChange

Changes.ResourceChange.Replacement

For the Modify action, indicates whether CloudFormation will replace the resource by creating a new one and deleting the old one. This value depends on the value of the RequiresRecreation property in the ResourceTargetDefinition structure. For example, if the RequiresRecreation field is Always and the Evaluation field is Static, Replacement is True. If the RequiresRecreation field is Always and the Evaluation field is Dynamic, Replacement is Conditional.

If you have multiple changes with different RequiresRecreation values, the Replacement value depends on the change with the most impact. A RequiresRecreation value of Always has the most impact, followed by Conditional, and then Never.

Type: String

Valid Values: True | False | Conditional

Required: No

DeepL 訳

Modify アクションの場合、CloudFormation が新しいリソースを作成して古いリソースを削除することによってリソースを置き換えるかどうかを示します。この値は、ResourceTargetDefinition構造体のRequiresRecreationプロパティの値に依存します。た と えば、 RequiresRecreation フィールドが Always で、 Evaluation フィールドが Static の場合、 Replacement は True にな り ます。RequiresRecreation フィールドが Always で、Evaluation フィールドが Dynamic の場合、Replacement は Conditional です。

RequiresRecreation 値が異なる複数の変更がある場合、Replacement 値は最も影響の大きい変更に依存します。RequiresRecreationの値がAlwaysの場合、最も影響が大きく、次にConditional、そしてNeverの順となります。

「This value depends on the value of the RequiresRecreation property in the ResourceTargetDefinition structure. 」 に記載してあるとおり ResourceTargetDefinition.RequiresRecreation に依存します。

  • the RequiresRecreation field is Never なら False
  • the RequiresRecreation field is Always and the Evaluation field is Static, Replacement is True
  • If the RequiresRecreation field is Always and the Evaluation field is Dynamic, Replacement is Conditional.

Changes.Details.member.N

Action が Modify のときにのみ表示され、 Cloudformation によるリソース変更の詳細リスト( a list of ResourceChangeDetail structures )です。

Details.member.N For the Modify action, a list of ResourceChangeDetail structures that describes the changes that CloudFormation will make to the resource.

Type: Array of ResourceChangeDetail objects

Required: No

ref.

ResourceChangeDetail

Changes.Details.Target

Target A ResourceTargetDefinition structure that describes the field that CloudFormation will change and whether the resource will be recreated.

Type: ResourceTargetDefinition object

Required: No

ResourceChangeDetail

ResourceTargetDefinition

Changes.Details.Target.RequiresRecreation

RequiresRecreation If the Attribute value is Properties, indicates whether a change to this property causes the resource to be recreated. The value can be Never, Always, or Conditionally. To determine the conditions for a Conditionally recreation, see the update behavior for that property in the AWS resource and property types reference in the AWS CloudFormation User Guide.

Type: String

Valid Values: Never | Conditionally | Always

Required: No

ResourceTargetDefinition

DeepLで翻訳

RequiresRecreation Attribute値がPropertiesの場合、このプロパティへの変更がリソースの再作成を引き起こすかどうかを示します。値には、Never、Always、または Conditionally を指定できます。Conditionallyの再作成の条件を決定するには、AWS CloudFormation User GuideのAWS resource and property types referenceのそのプロパティの更新動作を参照してください。

AWS リソースおよびプロパティタイプのリファレンス

RequiresRecreation の例

{
    "Type": "Resource",
    "ResourceChange": {
        "Action": "Modify",
        "LogicalResourceId": "WriteInstance",
        "PhysicalResourceId": "xxxxxxxxxx",
        "ResourceType": "AWS::RDS::DBInstance",
        "Replacement": "Conditional",
        "Scope": [
            "Properties"
        ],
        "Details": [
            {
                "Target": {
                    "Attribute": "Properties",
                    "Name": "DBParameterGroupName",
                    "RequiresRecreation": "Conditionally"
                },
                "Evaluation": "Static",
                "ChangeSource": "DirectModification"
            }
        ]
    }
}

AWS::RDS::DBInstance > DBParameterGroupName

Update requires: Some interruptions になっています。 Some interruptions は Understand update behaviors of stack resources に以下のように記載されています。

Updates with Some Interruption
AWS CloudFormation updates the resource with some interruption. For example, if you update certain properties on an AWS::EC2::Instance resource, the instance might have some interruption while AWS CloudFormation and Amazon EC2 reconfigure the instance.

ref. スタックリソースの更新動作を理解する

変更セット取得

AWS CLI で変更セットを取得できます。

$ aws cloudformation describe-change-set --change-set-name {{ change set name }} --stack-name {{ stack name }} --profile playground

変更セットの例

{
    "StackId": "arn:aws:cloudformation:us-east-1:123456789012:stack/SampleStack/1a2345b6-0000-00a0-a123-00abc0abc000",
    "Status": "CREATE_COMPLETE",
    "ChangeSetName": "SampleChangeSet-direct",
    "Parameters": [
        {
            "ParameterValue": "testing",
            "ParameterKey": "Purpose"
        },
        {
            "ParameterValue": "MyKeyName",
            "ParameterKey": "KeyPairName"
        },
        {
            "ParameterValue": "t2.micro",
            "ParameterKey": "InstanceType"
        }
    ],
    "Changes": [
        {
            "ResourceChange": {
                "ResourceType": "AWS::EC2::Instance",
                "PhysicalResourceId": "i-1abc23d4",
                "Details": [
                    {
                        "ChangeSource": "DirectModification",
                        "Evaluation": "Static",
                        "Target": {
                            "Attribute": "Tags",
                            "RequiresRecreation": "Never"
                        }
                    }
                ],
                "Action": "Modify",
                "Scope": [
                    "Tags"
                ],
                "LogicalResourceId": "MyEC2Instance",
                "Replacement": "False"
            },
            "Type": "Resource"
        }
    ],
    "CreationTime": "2020-11-18T23:35:25.813Z",
    "Capabilities": [],
    "StackName": "SampleStack",
    "NotificationARNs": [],
    "ChangeSetId": "arn:aws:cloudformation:us-east-1:123456789012:changeSet/SampleChangeSet-direct/1a2345b6-0000-00a0-a123-00abc0abc000"
}

ref. 変更セットのサンプル