How to update Athena output location using Cloudformation

爱⌒轻易说出口 提交于 2020-06-28 09:02:41

问题


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/

回答1:


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":


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




回答2:


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.



来源:https://stackoverflow.com/questions/61200196/how-to-update-athena-output-location-using-cloudformation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!