LoginSignup
2
0

More than 1 year has passed since last update.

Cloudfromationスタックに既存のリソースを紐付ける

Last updated at Posted at 2021-12-04

はじめに

最近Cloudfromationを触っているのアウトプットも兼ねて投稿です。

S3バケットを作成

advent-calendar-2021という名前のバケットを作成しておきます。

スクリーンショット 2021-12-03 10.43.35.png

Cloudformationスタックを作成

S3バケットを作成するだけの簡単なテンプレートでスタックを作成します。

AWSTemplateFormatVersion: "2010-09-09"
Resources:
  Test:
    Type: "AWS::S3::Bucket"
    DeletionPolicy: Retain
    Properties:
      BucketName: "advent-calendar-2021"

問題点

スタック作成時に以下のエラーがでてしまいます。作ろうとしたものと同じ名前のS3バケットが既に存在しますといった趣旨の内容です。

スクリーンショット 2021-12-03 10.57.02.png

解決方法

Cloudformationから既存のリソースをインポートします。
スクリーンショット 2021-12-03 11.06.23.png

先程と同じYMLファイルをアップロードします。
スクリーンショット 2021-12-03 11.07.53.png

S3バケットの名前を入力します
スクリーンショット 2021-12-03 11.08.59.png

画面操作を進めていきリソースをインポートします。
スクリーンショット 2021-12-03 11.14.22.png

インポートが完了しました
image.png

補足: Cloudfromationのスタックは一旦削除して作り直しました。

インポートできるリソース一覧

Cloudformationでインポートできるリソース一覧を見つけたのでURLを貼ります。
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import-supported-resources.html

おわりに

最後までご覧いただきありがとうございました。

2
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
2
0