cloudtools / cloudtools/troposphere

Import bash script as UserData in AWS CFN template using Troposphere

Open
#1,711 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
4.9k
Forks
1.4k
PR merge metrics
No merged PRs in 30d

Description

0

I am trying to create an AWS template using Troposphere and I am stuck at a point where I have to use my Bash Script as UserData. My main problem being Ref used in Bash Script. I am importing Bash Script as a file read and encode them to Base64 as:

UserData= Base64(Join("", [open('path to my bashscript', "r").read() .splitlines(True)]))

My bash script has Ref used as:
#!/bin/bash
set -x
export -f check_instance_service_status
timeout Ref('ValueReferenced') bash -c "check_instance_service_status $ELB_NAME"

The output I am getting is:
"#!/bin/bash\n",
"set -x\n",
"\n",
" export -f check_instance_service_status\n",
" timeout Ref('ValueReferenced') bash -c \"check_instance_service_status $ELB_NAME\"\n",
" RC=$?\n",

However, I want the Ref to be converted to proper JSON compatible as:
" timeout \"",
{
"Ref": "ValueReferenced"
},

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.