🍻

CloudFormation 変更セットの応用

2023/12/30に公開

リソースの変更を伴わないテンプレートの変更の取り込み

リソースの現状のパラメータをテンプレートファイルに追記します。

$ cp -pi vpc.yml{,.000}
$ vi vpc.yml

$ diff -u vpc.yml{,.000}
--- vpc.yml     2023-12-29 01:18:45.284833660 +0000
+++ vpc.yml.000 2023-12-29 01:16:26.982497392 +0000
@@ -11,8 +11,6 @@
     Type: AWS::EC2::VPC
     Properties:
       CidrBlock: !Ref CidrBlock
-      EnableDnsSupport: true
-      EnableDnsHostnames: false
       Tags:
       - Key: Name
         Value: !Sub "${SystemName}_vpc"

変更セットの仕組みを利用して、スタックを更新します。

$ aws cloudformation create-change-set --stack-name <stack_name> --template-body file://vpc.yml --parameters file://parameter.json --change-set-name <change_set_name> --description 'update template file'
{
    "StackId": "arn:aws:cloudformation:<region>:<aws_account_id>:stack/<stack_name>/b4e20e60-a5c8-11ee-8c99-0676a70102b5",
    "Id": "arn:aws:cloudformation:<region>:<aws_account_id>:changeSet/<change_set_name>/f6c62ea0-eb4c-4e3b-8f69-97cb91290238"
}

$ aws cloudformation list-change-sets --stack-name <stack_name>
{
    "Summaries": [
        {
            "StackId": "arn:aws:cloudformation:<region>:<aws_account_id>:stack/<stack_name>/b4e20e60-a5c8-11ee-8c99-0676a70102b5",
            "Status": "CREATE_COMPLETE",
            "ChangeSetName": "<change_set_name>",
            "Description": "update template file",
            "CreationTime": "2023-12-29T01:05:44.857Z",
            "StackName": "<stack_name>",
            "ExecutionStatus": "AVAILABLE",
            "ChangeSetId": "arn:aws:cloudformation:<region>:<aws_account_id>:changeSet/<change_set_name>/f6c62ea0-eb4c-4e3b-8f69-97cb91290238"
        }
    ]
}

想定される構成変更を確認します。

$ aws cloudformation describe-change-set --stack-name <stack_name> --change-set-name <change_set_name>                                                                                                         [6/1872]
{
    "StackId": "arn:aws:cloudformation:<region>:<aws_account_id>:stack/<stack_name>/b4e20e60-a5c8-11ee-8c99-0676a70102b5",
    "Status": "CREATE_COMPLETE",
    "ChangeSetName": "<change_set_name>",
    "Description": "update template file",
    "Parameters": [
        {
            "ParameterValue": "10.0.0.0/16",
            "ParameterKey": "CidrBlock"
        },
        {
            "ParameterValue": "zenn-test",
            "ParameterKey": "SystemName"
        }
    ],
    "Tags": null,
    "ChangeSetId": "arn:aws:cloudformation:<region>:<aws_account_id>:changeSet/<change_set_name>/f6c62ea0-eb4c-4e3b-8f69-97cb91290238",
    "CreationTime": "2023-12-29T01:05:44.857Z",
    "StatusReason": null,
    "StackName": "<stack_name>",
    "NotificationARNs": [],
    "Capabilities": [],
    "ExecutionStatus": "AVAILABLE",
    "Changes": [
        {
            "ResourceChange": {
                "ResourceType": "AWS::EC2::VPC",
                "PhysicalResourceId": "vpc-088d128811eb40c93",
                "Details": [
                    {
                        "ChangeSource": "DirectModification",
                        "Evaluation": "Static",
                        "Target": {
                            "Attribute": "Properties",
                            "Name": "EnableDnsSupport",
                            "RequiresRecreation": "Never"
                        }
                    },
                    {
                        "ChangeSource": "DirectModification",
                        "Evaluation": "Static",
                        "Target": {
                            "Attribute": "Properties",
                            "Name": "EnableDnsHostnames",
                            "RequiresRecreation": "Never"
                        }
                    }
                ],
                "Action": "Modify",
                "Scope": [
                    "Properties"
                ],
                "LogicalResourceId": "VPC",
                "Replacement": "False"
            },
            "Type": "Resource"
        }
    ],
    "RollbackConfiguration": {}
}

変更セットを適用します。

$ aws cloudformation execute-change-set --stack-name <stack_name> --change-set-name <change_set_name>

$ aws cloudformation list-change-sets --stack-name <stack_name>
{
    "Summaries": []
}

スタックの状態を確認します。

$ aws cloudformation describe-stacks --stack-name <stack_name>
{
    "Stacks": [
        {
            "StackId": "arn:aws:cloudformation:<region>:<aws_account_id>:stack/<stack_name>/b4e20e60-a5c8-11ee-8c99-0676a70102b5",
            "DriftInformation": {
                "StackDriftStatus": "NOT_CHECKED"
            },
            "LastUpdatedTime": "2023-12-29T01:12:39.496Z",
            "Parameters": [
                {
                    "ParameterValue": "10.0.0.0/16",
                    "ParameterKey": "CidrBlock"
                },
                {
                    "ParameterValue": "zenn-test",
                    "ParameterKey": "SystemName"
                }
            ],
            "Tags": [],
            "Outputs": [
                {
                    "OutputKey": "IgwId",
                    "OutputValue": "igw-09a8a7cd70d9c64f3"
                },
                {
                    "OutputKey": "VpcId",
                    "OutputValue": "vpc-088d128811eb40c93"
                }
            ],
            "EnableTerminationProtection": false,
            "CreationTime": "2023-12-28T21:33:14.249Z",
            "StackName": "<stack_name>",
            "NotificationARNs": [],
            "StackStatus": "UPDATE_COMPLETE",
            "DisableRollback": false,
            "ChangeSetId": "arn:aws:cloudformation:<region>:<aws_account_id>:changeSet/<change_set_name>/f6c62ea0-eb4c-4e3b-8f69-97cb91290238",
            "RollbackConfiguration": {}
        }
    ]
}

リソースの変更差分検出、取り込み

意図的に設定差分を発生させます。
ここでは Webコンソールから、VPC の DNS settings の設定で Enable DNS hostnames のチェックボックスをオンにします。

$ aws ec2 describe-vpc-attribute --vpc-id vpc-088d128811eb40c93 --attribute enableDnsHostnames
{
    "VpcId": "vpc-088d128811eb40c93",
    "EnableDnsHostnames": {
        "Value": true
    }
}

差分を検出させます。
StackResourceDriftStatus の値が MODIFIED となっている項目が変更されている属性です。

$ aws cloudformation detect-stack-drift --stack-name <stack_name>
{
    "StackDriftDetectionId": "24359b40-a5e9-11ee-a939-0e334e7e4c55"
}

検出した差分を確認します。

$ aws cloudformation describe-stack-resource-drifts --stack-name <stack_name>
{
    "StackResourceDrifts": [
        {
            "StackId": "arn:aws:cloudformation:<region>:<aws_account_id>:stack/<stack_name>/b4e20e60-a5c8-11ee-8c99-0676a70102b5",
            "ActualProperties": "{\"Tags\":[{\"Key\":\"Name\",\"Value\":\"zenn-test_igw\"},{\"Key\":\"SystemName\",\"Value\":\"zenn-test\"}]}",
            "ResourceType": "AWS::EC2::InternetGateway",
            "Timestamp": "2023-12-29T01:25:25.842Z",
            "PhysicalResourceId": "igw-09a8a7cd70d9c64f3",
            "StackResourceDriftStatus": "IN_SYNC",
            "ExpectedProperties": "{\"Tags\":[{\"Value\":\"zenn-test_igw\",\"Key\":\"Name\"},{\"Value\":\"zenn-test\",\"Key\":\"SystemName\"}]}",
            "PropertyDifferences": [],
            "LogicalResourceId": "InternetGateway"
        },
        {
            "StackId": "arn:aws:cloudformation:<region>:<aws_account_id>:stack/<stack_name>/b4e20e60-a5c8-11ee-8c99-0676a70102b5",
            "ActualProperties": "{\"CidrBlock\":\"10.0.0.0/16\",\"EnableDnsSupport\":true,\"EnableDnsHostnames\":true,\"Tags\":[{\"Key\":\"SystemName\",\"Value\":\"zenn-test\"},{\"Key\":\"Name\",\"Value\":\"zenn-test_vpc\"}]}",
            "ResourceType": "AWS::EC2::VPC",
            "Timestamp": "2023-12-29T01:25:26.070Z",
            "PhysicalResourceId": "vpc-088d128811eb40c93",
            "StackResourceDriftStatus": "MODIFIED",
            "ExpectedProperties": "{\"CidrBlock\":\"10.0.0.0/16\",\"EnableDnsSupport\":true,\"EnableDnsHostnames\":false,\"Tags\":[{\"Value\":\"zenn-test_vpc\",\"Key\":\"Name\"},{\"Value\":\"zenn-test\",\"Key\":\"SystemName\"}]}",
            "PropertyDifferences": [
                {
                    "PropertyPath": "/EnableDnsHostnames",
                    "ActualValue": "true",
                    "ExpectedValue": "false",
                    "DifferenceType": "NOT_EQUAL"
                }
            ],
            "LogicalResourceId": "VPC"
        }
    ]
}

変更の取り込み

Webコンソールで変更した内容に合わせてテンプレートファイルを修正します。

$ cp -pi vpc.yml{,.002}
$ vi vpc.yml

$ diff -u vpc.yml{,.002}
--- vpc.yml     2023-12-29 01:29:00.701526271 +0000
+++ vpc.yml.002 2023-12-29 01:18:45.284833660 +0000
@@ -12,7 +12,7 @@
     Properties:
       CidrBlock: !Ref CidrBlock
       EnableDnsSupport: true
-      EnableDnsHostnames: true
+      EnableDnsHostnames: false
       Tags:
       - Key: Name
         Value: !Sub "${SystemName}_vpc"

変更セットの仕組みを利用して、スタックを更新します。

$ aws cloudformation create-change-set --stack-name <stack_name> --template-body file://vpc.yml --parameters file://parameter.json --change-set-name <change_set_name> --description 'change EnableDnsHostnames to true'
{
    "StackId": "arn:aws:cloudformation:<region>:<aws_account_id>:stack/<stack_name>/b4e20e60-a5c8-11ee-8c99-0676a70102b5",
    "Id": "arn:aws:cloudformation:<region>:<aws_account_id>:changeSet/<change_set_name>/9625debd-9d57-4e0b-aa3f-0e1248d8b571"
}

$ aws cloudformation list-change-sets --stack-name <stack_name>
{
    "Summaries": [
        {
            "StackId": "arn:aws:cloudformation:<region>:<aws_account_id>:stack/<stack_name>/b4e20e60-a5c8-11ee-8c99-0676a70102b5",
            "Status": "CREATE_COMPLETE",
            "ChangeSetName": "<change_set_name>",
            "Description": "change EnableDnsHostnames to true",
            "CreationTime": "2023-12-29T01:33:01.439Z",
            "StackName": "<stack_name>",
            "ExecutionStatus": "AVAILABLE",
            "ChangeSetId": "arn:aws:cloudformation:<region>:<aws_account_id>:changeSet/<change_set_name>/9625debd-9d57-4e0b-aa3f-0e1248d8b571"
        }
    ]
}

想定される構成変更を確認します。

$ aws cloudformation describe-change-set --stack-name <stack_name> --change-set-name <change_set_name>
{
    "StackId": "arn:aws:cloudformation:<region>:<aws_account_id>:stack/<stack_name>/b4e20e60-a5c8-11ee-8c99-0676a70102b5",
    "Status": "CREATE_COMPLETE",
    "ChangeSetName": "<change_set_name>",
    "Description": "change EnableDnsHostnames to true",
    "Parameters": [
        {
            "ParameterValue": "10.0.0.0/16",
            "ParameterKey": "CidrBlock"
        },
        {
            "ParameterValue": "zenn-test",
            "ParameterKey": "SystemName"
        }
    ],
    "Tags": null,
    "ChangeSetId": "arn:aws:cloudformation:<region>:<aws_account_id>:changeSet/<change_set_name>/9625debd-9d57-4e0b-aa3f-0e1248d8b571",
    "CreationTime": "2023-12-29T01:33:01.439Z",
    "StatusReason": null,
    "StackName": "<stack_name>",
    "NotificationARNs": [],
    "Capabilities": [],
    "ExecutionStatus": "AVAILABLE",
    "Changes": [
        {
            "ResourceChange": {
                "ResourceType": "AWS::EC2::VPC",
                "PhysicalResourceId": "vpc-088d128811eb40c93",
                "Details": [
                    {
                        "ChangeSource": "DirectModification",
                        "Evaluation": "Static",
                        "Target": {
                            "Attribute": "Properties",
                            "Name": "EnableDnsHostnames",
                            "RequiresRecreation": "Never"
                        }
                    }
                ],
                "Action": "Modify",
                "Scope": [
                    "Properties"
                ],
                "LogicalResourceId": "VPC",
                "Replacement": "False"
            },
            "Type": "Resource"
        }
    ],
    "RollbackConfiguration": {}
}

変更セットを適用します。

$ aws cloudformation execute-change-set --stack-name <stack_name> --change-set-name <change_set_name>

$ aws cloudformation list-change-sets --stack-name <stack_name>
{
    "Summaries": []
}

スタックの状態を確認します。

$ aws cloudformation describe-stacks --stack-name <stack_name>
{
    "Stacks": [
        {
            "StackId": "arn:aws:cloudformation:<region>:<aws_account_id>:stack/<stack_name>/b4e20e60-a5c8-11ee-8c99-0676a70102b5",
            "DriftInformation": {
                "StackDriftStatus": "NOT_CHECKED"
            },
            "LastUpdatedTime": "2023-12-29T01:34:20.014Z",
            "Parameters": [
                {
                    "ParameterValue": "10.0.0.0/16",
                    "ParameterKey": "CidrBlock"
                },
                {
                    "ParameterValue": "zenn-test",
                    "ParameterKey": "SystemName"
                }
            ],
            "Tags": [],
            "Outputs": [
                {
                    "OutputKey": "IgwId",
                    "OutputValue": "igw-09a8a7cd70d9c64f3"
                },
                {
                    "OutputKey": "VpcId",
                    "OutputValue": "vpc-088d128811eb40c93"
                }
            ],
            "EnableTerminationProtection": false,
            "CreationTime": "2023-12-28T21:33:14.249Z",
            "StackName": "<stack_name>",
            "NotificationARNs": [],
            "StackStatus": "UPDATE_COMPLETE",
            "DisableRollback": false,
            "ChangeSetId": "arn:aws:cloudformation:<region>:<aws_account_id>:changeSet/<change_set_name>/9625debd-9d57-4e0b-aa3f-0e1248d8b571",
            "RollbackConfiguration": {}
        }
    ]
}

既存リソースをスタックへインポート

CloudFormation外で作成したサブネットをスタックへインポートしてみます。
まずはCLIでサブネットを作成します。

$ aws ec2 create-subnet --availability-zone "<availability_zone>" --cidr-block "10.0.1.0/24" --vpc-id vpc-088d128811eb40c93
{
    "Subnet": {
        "MapPublicIpOnLaunch": false,
        "AvailabilityZoneId": "apne1-az4",
        "AvailableIpAddressCount": 251,
        "DefaultForAz": false,
        "SubnetArn": "arn:aws:ec2:<region>:<aws_account_id>:subnet/subnet-0681ceacdd8c39b17",
        "Ipv6CidrBlockAssociationSet": [],
        "VpcId": "vpc-088d128811eb40c93",
        "State": "available",
        "AvailabilityZone": "<availability_zone>",
        "SubnetId": "subnet-0681ceacdd8c39b17",
        "OwnerId": "<aws_account_id>",
        "CidrBlock": "10.0.1.0/24",
        "AssignIpv6AddressOnCreation": false
    }
}

スタックのテンプレートに、インポートするリソース(ここではサブネット)の情報を記載します。

$ cp -pi vpc.yml{,.001}
$ vi vpc.yml

$ diff -u vpc.yml{,.001}
--- vpc.yml     2023-12-29 07:05:26.078702617 +0000
+++ vpc.yml.001 2023-12-29 01:29:00.701526271 +0000
@@ -6,9 +6,6 @@
   SystemName :
     Type: String
     Default: "zenn_test"
-  CidrBlock1a:
-    Type: String
-    Default: "10.0.1.0/24"
 Resources:
   VPC:
     Type: AWS::EC2::VPC
@@ -36,17 +33,6 @@
         Ref: VPC
       InternetGatewayId:
         Ref: InternetGateway
-  Subnet1a:
-    Type: AWS::EC2::Subnet
-    DeletionPolicy: Retain
-    Properties:
-      VpcId: !Ref VPC
-      CidrBlock: !Ref CidrBlock1a
-      AvailabilityZone:
-         Fn::Select:
-         - '0'
-         - Fn::GetAZs:
-             Ref: AWS::Region
 Outputs:
   VpcId:
     Value: !Ref VPC

必要ならパラメータファイルも修正します。

$ cp -pi parameter.json{,.001}
$ vi parameter.json

$ jq . parameter.json
[
  {
    "ParameterValue": "10.0.0.0/16",
    "ParameterKey": "CidrBlock"
  },
  {
    "ParameterValue": "zenn-test",
    "ParameterKey": "SystemName"
  },
  {
    "ParameterValue": "10.0.1.0/24",
    "ParameterKey": "CidrBlock1a"
  }
]

インポート対象の既存のリソース(ここではサブネット)の情報を記載します。

$ jq . import.json
[
  {
    "ResourceType": "AWS::EC2::Subnet",
    "LogicalResourceId": "Subnet1a",
    "ResourceIdentifier": {
      "SubnetId": "subnet-0681ceacdd8c39b17"
    }
  }
]

変更セットを作成します。

$ aws cloudformation create-change-set --stack-name <stack_name> --template-body file://vpc.yml --parameters file://parameter.json --change-set-name <change_set_name> --description 'import subnet' --change-set-type IMPORT --resources-to-import file://import.json
{
    "StackId": "arn:aws:cloudformation:<region>:<aws_account_id>:stack/<stack_name>/b4e20e60-a5c8-11ee-8c99-0676a70102b5",
    "Id": "arn:aws:cloudformation:<region>:<aws_account_id>:changeSet/<change_set_name>/b805ab68-57b6-4773-a511-2a6e1cb43126"
}

$ aws cloudformation list-change-sets --stack-name <stack_name>
{
    "Summaries": [
        {
            "StackId": "arn:aws:cloudformation:<region>:<aws_account_id>:stack/<stack_name>/b4e20e60-a5c8-11ee-8c99-0676a70102b5",
            "Status": "CREATE_COMPLETE",
            "ChangeSetName": "<change_set_name>",
            "Description": "import subnet",
            "CreationTime": "2023-12-29T07:05:55.255Z",
            "StatusReason": "Verify that resources and their properties defined in the template match the intended configuration of the resource import to avoid unexpected changes.",
            "StackName": "<stack_name>",
            "ExecutionStatus": "AVAILABLE",
            "ChangeSetId": "arn:aws:cloudformation:<region>:<aws_account_id>:changeSet/<change_set_name>/b805ab68-57b6-4773-a511-2a6e1cb43126"
        }
    ]
}

想定される構成変更を確認します。

$ aws cloudformation describe-change-set --change-set-name <change_set_name> --stack-name <stack_name>
{
    "StackId": "arn:aws:cloudformation:<region>:<aws_account_id>:stack/<stack_name>/b4e20e60-a5c8-11ee-8c99-0676a70102b5",
    "Status": "CREATE_COMPLETE",
    "ChangeSetName": "<change_set_name>",
    "Description": "import subnet",
    "Parameters": [
        {
            "ParameterValue": "10.0.1.0/24",
            "ParameterKey": "CidrBlock1a"
        },
        {
            "ParameterValue": "10.0.0.0/16",
            "ParameterKey": "CidrBlock"
        },
        {
            "ParameterValue": "zenn-test",
            "ParameterKey": "SystemName"
        }
    ],
    "Tags": null,
    "ChangeSetId": "arn:aws:cloudformation:<region>:<aws_account_id>:changeSet/<change_set_name>/b805ab68-57b6-4773-a511-2a6e1cb43126",
    "CreationTime": "2023-12-29T07:05:55.255Z",
    "StatusReason": "Verify that resources and their properties defined in the template match the intended configuration of the resource import to avoid unexpected changes.",
    "StackName": "<stack_name>",
    "NotificationARNs": [],
    "Capabilities": [],
    "ExecutionStatus": "AVAILABLE",
    "Changes": [
        {
            "ResourceChange": {
                "ResourceType": "AWS::EC2::Subnet",
                "PhysicalResourceId": "subnet-0681ceacdd8c39b17",
                "Details": [],
                "Action": "Import",
                "Scope": [],
                "LogicalResourceId": "Subnet1a"
            },
            "Type": "Resource"
        }
    ],
    "RollbackConfiguration": {}
}

変更セットを適用します。

$ aws cloudformation execute-change-set  --change-set-name <change_set_name> --stack-name <stack_name>

$ aws cloudformation list-change-sets --stack-name <stack_name>
{
    "Summaries": []
}

スタックの状態を確認します。

$ aws cloudformation describe-stacks --stack-name <stack_name>
{
    "Stacks": [
        {
            "StackId": "arn:aws:cloudformation:<region>:<aws_account_id>:stack/<stack_name>/b4e20e60-a5c8-11ee-8c99-0676a70102b5",
            "DriftInformation": {
                "StackDriftStatus": "NOT_CHECKED"
            },
            "LastUpdatedTime": "2023-12-29T07:09:10.253Z",
            "Parameters": [
                {
                    "ParameterValue": "10.0.1.0/24",
                    "ParameterKey": "CidrBlock1a"
                },
                {
                    "ParameterValue": "10.0.0.0/16",
                    "ParameterKey": "CidrBlock"
                },
                {
                    "ParameterValue": "zenn-test",
                    "ParameterKey": "SystemName"
                }
            ],
            "Tags": [],
            "Outputs": [
                {
                    "OutputKey": "IgwId",
                    "OutputValue": "igw-09a8a7cd70d9c64f3"
                },
                {
                    "OutputKey": "VpcId",
                    "OutputValue": "vpc-088d128811eb40c93"
                }
            ],
            "EnableTerminationProtection": false,
            "CreationTime": "2023-12-28T21:33:14.249Z",
            "StackName": "<stack_name>",
            "NotificationARNs": [],
            "StackStatus": "IMPORT_COMPLETE",
            "DisableRollback": false,
            "ChangeSetId": "arn:aws:cloudformation:<region>:<aws_account_id>:changeSet/<change_set_name>/b805ab68-57b6-4773-a511-2a6e1cb43126",
            "RollbackConfiguration": {}
        }
    ]
}

テンプレートファイルとインポートしたAWSリソースの状態に設定差分がないか確認します。

$ aws cloudformation detect-stack-drift --stack-name <stack_name>
{
    "StackDriftDetectionId": "bf887b50-a619-11ee-870a-0a39c05abb89"
}

$ aws cloudformation describe-stack-drift-detection-status --stack-drift-detection-id bf887b50-a619-11ee-870a-0a39c05abb89
{
    "StackId": "arn:aws:cloudformation:<region>:<aws_account_id>:stack/<stack_name>/b4e20e60-a5c8-11ee-8c99-0676a70102b5",
    "StackDriftDetectionId": "bf887b50-a619-11ee-870a-0a39c05abb89",
    "StackDriftStatus": "IN_SYNC",
    "Timestamp": "2023-12-29T07:13:21.285Z",
    "DetectionStatus": "DETECTION_COMPLETE",
    "DriftedStackResourceCount": 0
}

検出した差分を確認します。

$ aws cloudformation describe-stack-resource-drifts --stack-name <stack_name>
{
    "StackResourceDrifts": [
        {
            "StackId": "arn:aws:cloudformation:<region>:<aws_account_id>:stack/<stack_name>/b4e20e60-a5c8-11ee-8c99-0676a70102b5",
            "ActualProperties": "{\"Tags\":[{\"Key\":\"Name\",\"Value\":\"zenn-test_igw\"},{\"Key\":\"SystemName\",\"Value\":\"zenn-test\"}]}",
            "ResourceType": "AWS::EC2::InternetGateway",
            "Timestamp": "2023-12-29T07:13:22.255Z",
            "PhysicalResourceId": "igw-09a8a7cd70d9c64f3",
            "StackResourceDriftStatus": "IN_SYNC",
            "ExpectedProperties": "{\"Tags\":[{\"Value\":\"zenn-test_igw\",\"Key\":\"Name\"},{\"Value\":\"zenn-test\",\"Key\":\"SystemName\"}]}",
            "PropertyDifferences": [],
            "LogicalResourceId": "InternetGateway"
        },
        {
            "StackId": "arn:aws:cloudformation:<region>:<aws_account_id>:stack/<stack_name>/b4e20e60-a5c8-11ee-8c99-0676a70102b5",
            "ActualProperties": "{\"AvailabilityZone\":\"<availability_zone>\",\"CidrBlock\":\"10.0.1.0/24\",\"VpcId\":\"vpc-088d128811eb40c93\"}",
            "ResourceType": "AWS::EC2::Subnet",
            "Timestamp": "2023-12-29T07:13:22.387Z",
            "PhysicalResourceId": "subnet-0681ceacdd8c39b17",
            "StackResourceDriftStatus": "IN_SYNC",
            "ExpectedProperties": "{\"CidrBlock\":\"10.0.1.0/24\",\"AvailabilityZone\":\"<availability_zone>\",\"VpcId\":\"vpc-088d128811eb40c93\"}",
            "PropertyDifferences": [],
            "LogicalResourceId": "Subnet1a"
        },
        {
            "StackId": "arn:aws:cloudformation:<region>:<aws_account_id>:stack/<stack_name>/b4e20e60-a5c8-11ee-8c99-0676a70102b5",
            "ActualProperties": "{\"CidrBlock\":\"10.0.0.0/16\",\"EnableDnsSupport\":true,\"EnableDnsHostnames\":true,\"Tags\":[{\"Key\":\"SystemName\",\"Value\":\"zenn-test\"},{\"Key\":\"Name\",\"Value\":\"zenn-test_vpc\"}]}",
            "ResourceType": "AWS::EC2::VPC",
            "Timestamp": "2023-12-29T07:13:23.146Z",
            "PhysicalResourceId": "vpc-088d128811eb40c93",
            "StackResourceDriftStatus": "IN_SYNC",
            "ExpectedProperties": "{\"CidrBlock\":\"10.0.0.0/16\",\"EnableDnsSupport\":true,\"EnableDnsHostnames\":true,\"Tags\":[{\"Value\":\"zenn-test_vpc\",\"Key\":\"Name\"},{\"Value\":\"zenn-test\",\"Key\":\"SystemName\"}]}",
            "PropertyDifferences": [],
            "LogicalResourceId": "VPC"
        }
    ]
}
  • 差分が確認されたら、テンプレートファイルを編集して、変更セットを作成・実行して、差分を取り込みます。
  • 不要なら、「DeletionPolicy: Retain」を削除します。
GitHubで編集を提案

Discussion