LoginSignup
11
4

More than 3 years have passed since last update.

CloudFormationがまだ、ECS FARGATEのタスクeventsのtarget定義をサポートしていない件 => されました。

Last updated at Posted at 2018-11-20

CloudFormationがまだ、ECS FARGATEのタスクeventsのtarget定義をサポートしていないんですよね・・・。

でもある程度、自動化したいですよね。

※2018/11/20 現在

2019-09-12 現在 サポートされてました!!!!

※英語ページのみ。日本語ページには反映されていない。

サンプル

  ECSS3SyncTaskSchedule:
    Type: AWS::Events::Rule
    Condition: CreateS3SyncResources
    Properties:
      State: ENABLED
      ScheduleExpression: cron(0 16 * * ? *)
      Name: "適当な名前" 
      Targets:
        - RoleArn: "eventsで使うロール" 
          EcsParameters:
            TaskDefinitionArn: "タスク定義のARN" 
            TaskCount: 1
            LaunchType: FARGATE
            NetworkConfiguration:
              AwsVpcConfiguration:
                Subnets:
                  - "利用するsubnet1" 
                  - "利用するsubnet2" 

よって下記の内容は過去です。

(以下は過去記事)代替案

CloudForamtionでイベントを作成した後、AWS CLI でターゲットだけ更新する

詳細

1. jsonを準備する(ファイル)

サンプル
※以降 <文字列> は適当な内容に上書きください。

sample.json
[
        {
            "RoleArn": "arn:aws:iam::<アカウントID>:role/<ロール名>",
            "EcsParameters": {
                "TaskDefinitionArn": "arn:aws:ecs:ap-northeast-1:<アカウントID>:task-definition/<タスク定義名>",
                "TaskCount": 1,
                "LaunchType": "FARGATE",
                "NetworkConfiguration": {
                  "awsvpcConfiguration": {
                    "Subnets": [
                      "<subnetID>",
                      "<subnetID>"
                    ]
                  }
                }
            },
            "Id": "<ターゲットID>",
            "Arn": "arn:aws:ecs:ap-northeast-1:<アカウントID>:cluster/<クラスタ名>"
        }
]

2. CLIコマンドで更新する

aws events put-targets --rule <ルール名> --targets file://sample.json

■AWSリリース履歴

対応要望はたくさん来ているようなので、下記サイトをフォローすると良いらしいです。
https://docs.aws.amazon.com/en_us/AWSCloudFormation/latest/UserGuide/ReleaseHistory.html

以上です。

11
4
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
11
4