shantanuo
shantanuo

Reputation: 32286

Update AWS Athena workgroup using CloudFormation template

I have 2 templates those I have taken from the AWS::Athena::WorkGroup - AWS CloudFormation documentation.

The first template athena_create.yaml works as expected. The second template needs to modify the workgroup created in the first template. But I get an error:

MyCustomWorkGroup already exists in stack arn:aws:cloudformation:us-east-1:XXX:stack/a1/7cc670a0-8d19-11ea-872c-12217e59f19f

Here is the code. create template works correctly.

athena_create.yaml

Resources:
  MyAthenaWorkGroup:
    Type: AWS::Athena::WorkGroup
    Properties:
      Name: MyCustomWorkGroup
      Description: My WorkGroup
      State: ENABLED
      Tags:
        - Key: "key1"
          Value: "value1"
        - Key: "key2"
          Value: "value2"
      WorkGroupConfiguration:
        BytesScannedCutoffPerQuery: 200000000
        EnforceWorkGroupConfiguration: false
        PublishCloudWatchMetricsEnabled: false
        RequesterPaysEnabled: true
        ResultConfiguration:
          OutputLocation: s3://path/to/my/bucket/

athena_update.yaml

Resources:
  MyAthenaWorkGroup:
    Type: AWS::Athena::WorkGroup
    Properties:
      Name: MyCustomWorkGroup
      Description: My WorkGroup Updated
      State: DISABLED
      Tags:
        - Key: "key1"
          Value: "value1"
        - Key: "key2"
          Value: "value2"
      WorkGroupConfigurationUpdates:
        BytesScannedCutoffPerQuery: 10000000
        EnforceWorkGroupConfiguration: true
        PublishCloudWatchMetricsEnabled: true
        RequesterPaysEnabled: false
        ResultConfigurationUpdates:
          EncryptionConfiguration:
            EncryptionOption: SSE_S3
          OutputLocation: s3://path/to/my/bucket/updated/

The update template mentioned above does not work as expected.

Upvotes: 0

Views: 1404

Answers (1)

Marcin
Marcin

Reputation: 238687

The reason for the error is that the two templates were used to create two independent stacks. This didn't work because they two Athena WorkGroups of same Name: MyCustomWorkGroup.

The correct way to perform create and update the MyCustomWorkGroup is as follows:

  1. Create a stack using athena_create.yaml file.

  2. Once the stack is created, use its Update option to upload athena_update.yaml which is going to update the stack.

Upvotes: 1

Related Questions