1

I have nginx configuration files which I would like to deploy on my Ubuntu EC2 instance. I create instance using AWS CLI:

  aws ec2 run-instances --instance-type t2.micro \
    --count 1 \
    --image-id ami-0f8b8babb98cc66d0 \
    --key-name "$key_name" \
    --tag-specifications "ResourceType=instance,Tags=[{Key=Name,Value=$name}]" \
    --query "Instances[0].{$instance_fields_selection}" \
    --user-data 'file://ec2-setup'

This mostly works as expected: ec2-setup script creates some folders, installs some packages and does reboot. But I still have to upload my nginx config files manually through scp. --user-data option seems to be intended for uploading files, but in fact it is used for passing initialization script. Is it possible to toss normal non-executable file on instance when creating it using AWS CLI?

vatosarmat
  • 131
  • 4

1 Answers1

1

Inside your user-data script you can specify all commands you need to prepare the OS. Then, it's inside the user-data script that you'll scp something.

However, you can't inject files inside your instance without scp or s3 commands in your user-data script.

Martin
  • 474
  • 1
  • 11