I am running a basic hello world application on my ec2 instance. The infrastructure is all setup and I am able to ssh into it.
The code for creating my instance looks like below. I have a simple user_data variable for now, but I know I need to utilize this. I also have a simple html file that says "hello world" as well as a helloworld.py file which just serves the html file.
How would I utilize the user_data (I am having trouble with the syntax) to push the html and helloworld.py file to my ec2 instance then run the script so that the file is served? I am a noobie to nginx and stuff so looking for some direction here...
user_data = '''#!/bin/bash
echo 'test' > /tmp/hello'''
create_instance = resourceEC2.create_instances(
ImageId = data['ImageId_value'],
MinCount = 1,
MaxCount = 1,
InstanceType = data['InstanceType_value'],
SubnetId=data['SubnetId-1a'],
UserData=user_data,
SecurityGroupIds=[
security_group_TG['GroupId'],
],
)