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?

More than 5 years have passed since last update.

AWS Cloud MapのInstanceをCloudFormationで更新する際にエラー

Posted at

少々挙動がわかりにくかったのでメモ。

エラー内容

The following resource(s) failed to create: [FIZZBUZZ].
xxxx|fizz already exists in stack arn:aws:cloudformation:ap-northeast-1:xxx:stack/service-map2/xxx-xxx-xxx

原因

  • 論理IDを変更した結果InstanceIdが重複するから

再現手順

以下のCFテンプレートをデプロイ。

AWSTemplateFormatVersion: '2010-09-09'

Resources:
  # Namespaces
  NS:
    Type: AWS::ServiceDiscovery::HttpNamespace
    Properties:
      Name: foo.local

  S:
    Type: AWS::ServiceDiscovery::Service
    Properties:
      Name: bar
      NamespaceId: !GetAtt NS.Id

  FIZZ:
    Type: AWS::ServiceDiscovery::Instance
    Properties:
      InstanceAttributes:
        env: staging
      InstanceId: fizz
      ServiceId: !GetAtt S.Id

次に、論理ID FIZZ を変更してデプロイ。

AWSTemplateFormatVersion: '2010-09-09'

Resources:
  # Namespaces
  NS:
    Type: AWS::ServiceDiscovery::HttpNamespace
    Properties:
      Name: foo.local

  S:
    Type: AWS::ServiceDiscovery::Service
    Properties:
      Name: bar
      NamespaceId: !GetAtt NS.Id

  FIZZBUZZ:
    Type: AWS::ServiceDiscovery::Instance
    Properties:
      InstanceAttributes:
        env: staging
      InstanceId: fizz
      ServiceId: !GetAtt S.Id

で、エラー発生。
InstanceId が重複するから、というのが理由らしい。CFのその他のリソースではそこらへんうまいことやってくれる印象だが、Cloud Mapのインスタンスでは論理IDのみを変えるとエラーが発生するので注意。

InstanceId を変更すれば無事に通る。内部的には新論理IDの作成->無くなった論理IDの除却という挙動をするための模様。
image.png

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?