cloudformation-coverage-roadmap icon indicating copy to clipboard operation
cloudformation-coverage-roadmap copied to clipboard

[Feature Request] Support updating of tags on existing AWS::WAFv2::WebACL resources

Open greg5123334 opened this issue 4 years ago • 1 comments

Name of the resource

AWS::WAFv2::WebACL

Resource name

No response

Description

I am unable to update the tags of AWS::WAFv2::WebACL resources. According to literature,

To modify tags on existing resources, use the AWS WAF APIs or command line interface. With AWS CloudFormation, you can only add tags to AWS WAF resources during resource creation.

Reproduction

This limitation can be observed by doing the following:

  1. Create stack with AWS::WAFv2::WebACL resource.

aws cloudformation create-stack --stack-name demo --template-body file://template.yaml template.yaml

Resources:
  MyACL:
    Type: 'AWS::WAFv2::WebACL'
    Properties:
      Name: MyDummyDeployment
      Scope: REGIONAL
      DefaultAction:
        Allow:
          CustomRequestHandling:
            InsertHeaders:
              - Name: AllowRequests
                Value: myRequest
      Tags:
        - Key: Name
          Value: Dummy
      VisibilityConfig:
        CloudWatchMetricsEnabled: True
        MetricName: DummyMetrics
        SampledRequestsEnabled: True

  1. Add or modify tags in template, and update stack.

template.yaml

Resources:
  MyACL:
    Type: 'AWS::WAFv2::WebACL'
    Properties:
      Name: MyDummyDeployment
      Scope: REGIONAL
      DefaultAction:
        Allow:
          CustomRequestHandling:
            InsertHeaders:
              - Name: AllowRequests
                Value: myRequest
      Tags:
        - Key: Name
          Value: Dummy
        - Key: test-tag
          Value: 'ifyouseethisitsworking'
      VisibilityConfig:
        CloudWatchMetricsEnabled: True
        MetricName: DummyMetrics
        SampledRequestsEnabled: True

aws cloudformation update-stack --stack-name demo --template-body file://template.yaml

  1. Test By means of the list-tags-for-resource CLI command, we can see this resource contains only the original tag(s), but not that which were included in the update op.

3.1 Grab Resource ARN using get-web-acl. aws wafv2 get-web-acl --name MyDummyDeployment --scope REGIONAL --id xxxxxxxx-9ad9-4909-a52a-xxxxxxxxxxx

3.2 List Tags using list-tags-for-resource aws wafv2 list-tags-for-resource --resource-arn arn:aws:wafv2:eu-west-1:0000000000:regional/webacl/MyDummyDeployment/xxxxxxx-9ad9-4909-a52a-xxxxxxxxx

The new/modified tag(s) will NOT be found.

Workaround

One can workaround this limitation by means of a multi-phased stack update operation.

  1. Temporarily rename the logical identifier of the AWS::WAFv2::WebACL resource, as well as its Name property (to avoid conflicts). Update stack.

  2. Add/modify tags as desired.

  3. Revert Name and identifier AWS::WAFv2::WebACL resource back to original. Update stack.

This can be expected to replace the AWS::WAFv2::WebACL resource to include the tags in their desired state.

Conclusion

As a user, it would be nice if Cloudformation could take care of updating tags on my behalf, to save myself the otherwise manual effort.

Please let me know if further information is required from my side.

Other Details

No response

greg5123334 avatar Jan 30 '22 06:01 greg5123334

As indicated in the documentation, updating of tags in CloudFormation is not supported. This is consistent with the WAFv2 API for CreateWebACL (tags supported), and UpdateWebACL (tags not supported).

jerechenamz avatar Mar 01 '22 17:03 jerechenamz