mikesouza / serverless-deployment-bucket

Create and configure the custom Serverless deployment bucket.
MIT License
48 stars 23 forks source link

Cannot add tags to existing deployment bucket #55

Closed dprotsiv closed 2 years ago

dprotsiv commented 3 years ago

Version: 1.5.1 Issue:

For existing deployment bucket, after configuring "tags" property with new tags, it is not possible to add new tags. This seem to only work when bucket is either being created or if the bucket has at least one tag.

Steps to reproduce: Step 1: Configure vanilla serverless.yml with serverless-deployment-bucket. Bucket configuration in custom section:

  deploymentBucket:
    enabled: true

Then deploy (no tags).

Step 2: Change deploymentBucket to following:

  deploymentBucket:
    enabled: true
    tags:
      - Key: Environment
        Value: production

Then deploy - observe that bucket tags are empty.

Preliminary issue notes: Best I can surmise is that issue itself comes from DeploymentBucketPlugin.hasChangedBucketTags in index.json where const response = await this.provider.request('S3', 'getBucketTagging', { Bucket: name }) throws an exception: {"code":"AWS_S3_GET_BUCKET_TAGGING_NO_SUCH_TAG_SET","providerError":{"message":"The TagSet does not exist","code":"NoSuchTagSet","region":null,"time":"2021-06-28T17:46:11.101Z","requestId":".....","extendedRequestId":".......","statusCode":404,"retryable":false,"retryDelay":94.99932161936133},"providerErrorCodeExtension":"NO_SUCH_TAG_SET"} And has DeploymentBucketPlugin.hasChangedBucketTags returns false. This in turn causes applyDeploymentBucket to not apply new tags

dalecampbell commented 3 years ago

I can attest to this being the case. In fact I found a way through testing to get the tags to apply.

  1. Add tags with Environment being first in the list.
  2. Add Environment tag to the bucket manually with a matching value.
  3. Add another random tag not already in your list with random value
  4. sls deploy

All your tags will be created and will persist through deployments if no changes are made to the tags

jchou1271 commented 3 years ago

+1 ran into the same issue. Any update on a fix for this?

ROSeaboyer commented 2 years ago

I just put up a PR to fix this issue; I've been hitting it as well and that change should fix it

mikesouza commented 2 years ago

@ROSeaboyer Thanks, merged and released in v1.5.2!