Adding tags to the aws ec2 instances

Hi,

I’m relatively new to running aws ec2 instances. Our IT dept requires us to provide tags during ec2 instance creation. I’ve tried running ray up using a basic YAML (supplied below), however I get the follow error. Any help would be appreciated. Thanks.

’ File “/home/abc/anaconda3/envs/cv-trial/lib/python3.9/site-packages/ray/scripts/scripts.py”, line 1923, in main
return cli()
File “/home/lauren/anaconda3/envs/cv-trial/lib/python3.9/site-packages/click/core.py”, line 829, in call
return self.main(*args, **kwargs)
File “/home/lauren/anaconda3/envs/cv-trial/lib/python3.9/site-packages/click/core.py”, line 782, in main
rv = self.invoke(ctx)
File “/home/lauren/anaconda3/envs/cv-trial/lib/python3.9/site-packages/click/core.py”, line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/lauren/anaconda3/envs/cv-trial/lib/python3.9/site-packages/click/core.py”, line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/lauren/anaconda3/envs/cv-trial/lib/python3.9/site-packages/click/core.py”, line 610, in invoke
return callback(*args, **kwargs)
File “/home/lauren/anaconda3/envs/cv-trial/lib/python3.9/site-packages/ray/scripts/scripts.py”, line 936, in up
create_or_update_cluster(
File “/home/lauren/anaconda3/envs/cv-trial/lib/python3.9/site-packages/ray/autoscaler/_private/commands.py”, line 242, in create_or_update_cluster
get_or_create_head_node(config, config_file, no_restart, restart_only, yes,
File “/home/lauren/anaconda3/envs/cv-trial/lib/python3.9/site-packages/ray/autoscaler/_private/commands.py”, line 633, in get_or_create_head_node
provider.create_node(head_node_config, head_node_tags, 1)
File “/home/lauren/anaconda3/envs/cv-trial/lib/python3.9/site-packages/ray/autoscaler/_private/aws/node_provider.py”, line 312, in create_node
created_nodes_dict = self._create_node(node_config, tags, count)
File “/home/lauren/anaconda3/envs/cv-trial/lib/python3.9/site-packages/ray/autoscaler/_private/aws/node_provider.py”, line 344, in _create_node
for user_tag in user_tag_spec[“Tags”]:
KeyError: ‘Tags’

YAML (basic template provided by Ray)

# An unique identifier for the head node and workers of this cluster.
cluster_name: minimal

# Cloud-provider specific configuration.
provider:
    type: aws
    region: ap-southeast-2


available_node_types:
    ray.head.default:
        node_config:
            InstanceType: m5.large
            ImageId: ami-039801274835e0d08 # Deep Learning AMI  Version 30
            TagSpecifications: 
              - 'ResourceType': 'instance'
              - 'Tags': {'Key': 'CostCode', 'Value': '1234'}
    
    ray.worker.default:
        # http://boto3.readthedocs.io/en/latest/reference/services/ec2.html#EC2.ServiceResource.create_instances
        node_config:
            InstanceType: m5.large
            SecurityGroups: ['my-group']
            ImageId: ami-039801274835e0d08 # Deep Learning AMI  Version 30
            TagSpecifications: 
              - 'ResourceType': 'instance'
              - 'Tags': {'Key': 'CostCode', 'Value': '1234'}

I have a similar issue and I think you are very close! Try removing the - before ‘Tags’ in your YAML file like this:

TagSpecifications:
- ‘ResourceType’: ‘instance’
‘Tags’: {‘Key’: ‘CostCode’, ‘Value’: ‘1234’}

Update: it worked for me.