Tags not getting added/updated after adding in AWS Glue Job and Crawler in SAM Template

Viewed 830
MainGlueJob:
    Type: AWS::Glue::Job
    Properties:
      Name: !Ref GlueJobName
      Role: !Ref GlueResourcesServiceRoleName
      Description: Job created with CloudFormation.
      GlueVersion: 2.0
      Command:
        Name: glueetl
        PythonVersion: 3
        ScriptLocation: !Ref JobScriptLocation
      AllocatedCapacity: 3
      ExecutionProperty:
        MaxConcurrentRuns: 1
      DefaultArguments:
        --job-bookmark-option: job-bookmark-enable
        --enable-continuous-cloudwatch-log: true
        --enable-metrics: true
        --enable-s3-parquet-optimized-committer: true
        --TempDir: 's3://aws-glue-temporary-123-ap-south-1/dir'
      Tags: {
        "tag:Key1": "Value1",
        "tag:Key2": "Value2"
      }

  MainCrawler:
    Type: AWS::Glue::Crawler
    Properties:
      Name: Main
      Role: !Ref GlueResourcesServiceRoleName
      Description: AWS Glue crawler
      DatabaseName: !Ref DatabaseName
      Targets:
        S3Targets:
          - Path: !Ref S3Path
      SchemaChangePolicy:
        UpdateBehavior: "UPDATE_IN_DATABASE"
        DeleteBehavior: "LOG"
      Configuration: '{"Version":1.0,"CrawlerOutput":{"Partitions":{"AddOrUpdateBehavior":"InheritFromTable"},"Tables":{"AddOrUpdateBehavior":"MergeNewColumns"}}}'
      Tags: {
        "tag:Key1": "Value1",
        "tag:Key2": "Value2"
      }

Trying to define tags in SAM Template for glue jobs but not getting updated in glue job or crawler

Tags: {
    "tagKeyName1": "tagValue1",
    "tagKeyName2": "tagValue2",
    "tagKeyName3": "tagValue3"
  }

I can only update glue resources with tags as the glue jobs are already in use. Deletion and recreation of stack will cost us a lot as Glue job bookmarks can't be controlled by user.

I'm using SAM Template and trying to add tags to Glue Job and Crawler.

Anyway to update the resources with tags ?

What is the correct format for declaring tags in SAM Template for Glue resources ?

Anyone wants to help ?

1 Answers

You can try:

Tags: {
    tagKeyName1: !Ref tagValue1
    tagKeyName2: !Ref tagValue2
    tagKeyName3: !Ref tagValue3
  }

This must be in JSON format: do not use quotation marks or braces.

Related