0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

HULFT10 for Container Services のスタックリソースをリネームしてみた

0
Posted at

はじめに

こんにちは。すぎもんです。:smiley:

HULFT10 for Container Services を Ver.10.5.0 未満から Ver.10.5.0 以降へアップデートする場合、事前作業として CloudFormation スタックリソースのリネームが必要になります。

今回の記事では、AWS CloudFormation のスタックリファクタリング機能を利用して、以下 2 つのリソースをリネームする手順を紹介します。

  • FargateSecurityGroup
  • FargateVPC

公式ドキュメント と記事についてもあわせて参照してください。

実施手順

今回の作業は以下の流れで実施します。

  1. リネーム対象スタックIDの取得
  2. スタックリファクタリング設定ファイルの作成
  3. スタックリファクタリングの実行
  4. 実行結果の確認

1. リネーム対象スタックIDの取得

AWS CloudFormation コンソールから、以下 2 つのスタックのスタックIDを取得します。

FargateSecurityGroup
CloudFormation NewDeployTemplate1
└─ Network1
   └─ FargateSecurityGroup
FargateVPC
CloudFormation NewDeployTemplate1
└─ Network1
   └─ FargateVPC

対象スタックの詳細画面からスタックIDを控えておきます。

image.png

2. スタックリファクタリング設定ファイルの作成

refactor1.json の作成

まずは FargateSecurityGroup 用の設定ファイルを作成します。

以下を refactor1.json としてローカルに保存してください。

[
  {
    "Source": {
      "StackName": "<FargateSecurityGroupのスタックID>",
      "LogicalResourceId": "FargateSGForBastionSrever"
    },
    "Destination": {
      "StackName": "<FargateSecurityGroupのスタックID>",
      "LogicalResourceId": "FargateSGForBastionServer"
    }
  }
]

FargateSecurityGroupのスタックID は事前に取得したスタックIDへ置き換えてください。

定義ファイルの内容は、導入時に指定したパラメーター「SourceIP1」、「SourceIP2」、「SourceIP3」の設定により変わります。

refactor2.json の作成

続いて FargateVPC 用の設定ファイルを作成します。

以下を refactor2.json としてローカルに保存します。

[
  {
    "Source": {
      "StackName": "<FargateVPCのスタックID>",
      "LogicalResourceId": "PublicSubnetForBastionSrever"
    },
    "Destination": {
      "StackName": "<FargateVPCのスタックID>",
      "LogicalResourceId": "PublicSubnetForBastionServer"
    }
  }
]

FargateVPCのスタックID は取得したスタックIDへ置き換えてください。

3. スタックリファクタリングの実行

CloudFormation のスタックリファクタリング機能を利用してリソース名を変更します。

実施手順は以下のとおりです。

① スタックリファクターの作成
② スタックリファクターの状態確認
③ スタックリファクターの実行

① スタックリファクターの作成

まずはリファクターを作成し、StackRefactorId を取得します。

FargateSecurityGroup
aws cloudformation create-stack-refactor \
  --stack-definitions StackName=<FargateSecurityGroupのスタックID>,TemplateURL=https://hulft-marketplace-resources.s3.amazonaws.com/CFn_10.5.0_20251003/UpdateTemplates/refactoring/security-group.yaml \
  --no-enable-stack-creation \
  --resource-mappings file://refactor1.json
FargateVPC
aws cloudformation create-stack-refactor \
  --stack-definitions StackName=<FargateVPCのスタックID>,TemplateURL=https://hulft-marketplace-resources.s3.amazonaws.com/CFn_10.5.0_20251003/UpdateTemplates/refactoring/vpc.yaml \
  --no-enable-stack-creation \
  --resource-mappings file://refactor2.json

POINT
レスポンスに含まれる StackRefactorId は後続手順で利用するため控えておきます。

② スタックリファクターの状態確認

取得した StackRefactorId ごとに以下のコマンドを実行します。

aws cloudformation describe-stack-refactor \
  --stack-refactor-id <StackRefactorId>

レスポンス内の Status が以下になっていることを確認します。

CREATE_COMPLETE

image.png

[SSL: CERTIFICATE_VERIFY_FAILED] エラーが発生したため、--no-verify オプションを追加しています。

③ スタックリファクターの実行

状態確認後、スタックリファクターを実行します。

aws cloudformation execute-stack-refactor \
  --stack-refactor-id <StackRefactorId>

取得した 2 つの StackRefactorId に対して実施します。

4. 実行結果の確認

リネーム後、CloudFormation のリソース一覧を確認します。

FargateSecurityGroup

以下のリソースが存在することを確認します。

FargateSGForBastionServer

FargateVPC

以下のリソースが存在することを確認します。

PublicSubnetForBastionServer

期待するリソース名で表示されていれば、スタックリソースのリネームは成功です。

image.png

まとめ

HULFT10 for Container Services を Ver.10.5.0 以降へアップデートする際は、CloudFormation のスタックリファクタリング機能を利用した事前リネーム作業が必要になります。

今回の手順では、

  • 対象スタックIDの取得
  • リファクタリング設定ファイルの作成
  • スタックリファクターの作成と実行
  • リネーム結果の確認

という流れで対応しました。

アップデート前の事前準備として実施しておくことで、Ver.10.5.0 以降への移行をスムーズに進めることができます。

このブログでは、今後も様々なTopics記事や接続検証等、皆さんの参考になるような記事を投稿していきたいと思います!
ここまで読んでいただきありがとうございました。それでは、また!:wave:

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?