I hope you are all well.
I want to create an instance for a cluster using ruby.
First, I created the client:
client = Aws::ECS::Client.new(Client.params)
After that, I tried to prepare a variable for the user_data field:
user_data = message = Base64.encode64("#!/bin/bash\necho ECS_CLUSTER=test >> /etc/ecs/ecs.config\n")
And last, but not least, I tried to create the instance using the run_instances method:
client.run_instances({
image_id: '<image-id>',
instance_type: '<instance-type>',
key_name: '<key-name>',
max_count: 1,
min_count: 1,
user_data: user_data,
monitoring: { enabled: false },
security_group_ids: ['<security-group-ids>'],
iam_instance_profile: {
name: '<iam-instance-profile>'
}
})
The instance is created, but the contents of the ecs.config file are empty. I'm not sure what I'm doing wrong.
I was hoping that the file would have ECS_CLUSTER=test
inside.
Can anyone give me a hint of how to solve this, please?
Thank you!