I am creating EC2 instance and want to pass user data to attach a filesystem, but I don't know how to pass file system ID as a variable.
The file system ID will be passed using the API gateway. I have tried following but user data contains $aa not aa values.
aa='fs-ce99bd38'
user_data = """#!bin/bash
sudo yum -y install nfs-utils
sudo mount -t efs -o tls $aa:/ efs
"""
client = boto3.client('ec2', region_name=REGION)
def lambda_handler(event, context):
instance = client.run_instances(
ImageId=AMI,
InstanceType=INSTANCE_TYPE,
KeyName=KEY_NAME,
UserData=user_data,
MaxCount=min_max_add,
MinCount=min_max_add
)