user1550159
user1550159

Reputation: 1267

How to update Athena output location using Cloudformation

Can someone help me write a Cloud formation script to update output location of Athena primary workgroup. When i run below code, getting error message "Invalid request provided: primary workGroup could not be created (Service: Athena, Status Code: 400, Request ID: 9945209c-6999-4e8b-bd3d-a3af13b4ac4f)"

Resources:
  MyAthenaWorkGroup:
    Type: AWS::Athena::WorkGroup
    Properties:
      Name: primary
      Description: My WorkGroup Updated
      State: DISABLED
      WorkGroupConfigurationUpdates:
        BytesScannedCutoffPerQuery: 10000000
        EnforceWorkGroupConfiguration: true
        PublishCloudWatchMetricsEnabled: true
        RequesterPaysEnabled: false
        ResultConfigurationUpdates:
          EncryptionConfiguration:
            EncryptionOption: SSE_S3          
          OutputLocation: s3://test/

Upvotes: 2

Views: 1702

Answers (2)

gcbenison
gcbenison

Reputation: 11963

Why not name the workgroup in your cloudformation stack something other than "primary", and let the stack manage the workgroup resource completely? Then, depending on how the rest of the system is set up, it may work out to use this new workgroup instead of the primary one. Even if you do get it working to alter the primary workgroup output location in CF, I think it's clear that's going upstream against CF's most natural usage patterns.

Upvotes: 1

Alexandre Andrade
Alexandre Andrade

Reputation: 555

you need to "create a change set to import an existing resource into a new or existing stack.", because the 'primary' workgroup was created outside your stack. So you need to use the option: "Create stack with existing resources":

enter image description here


You also need to add DeletionPolicy/UpdateReplacePolicy. An complete working example is:

  Resources:
    AthenaPrimaryWorkGroup:
      Type: AWS::Athena::WorkGroup
      Properties:
        Name: primary
        State: ENABLED
        WorkGroupConfigurationUpdates:
          BytesScannedCutoffPerQuery: 1000000000
          EnforceWorkGroupConfiguration: true
          PublishCloudWatchMetricsEnabled: true
          RequesterPaysEnabled: false
          ResultConfigurationUpdates:
            OutputLocation: s3://MY-Athena-results
      DeletionPolicy: Retain
      UpdateReplacePolicy: Retain

More detail at: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import.html

Upvotes: 7

Related Questions