Use DynamoDB to have a centralized location flag variable that can be accessed from multiple EC2 instances
- Create DynamoDB table, call it GlobalVariable.
- Primary key: name = id, type = number
- Sort key field: name = flag, type = String
- Add item to table using your value with key id # - example below uses 42.
- add your flag variable value in "flag" field beginning with "val-", for example: val-youareawesome
The below command will get only the variable value from DynamoDB
aws dynamodb query --table-name GlobalVariable --key-condition-expression "id = :id and begins_with(flag, :dt)" --expression-attribute-values '{":id":{"N":"42"},":dt":{"S":"val-"}}'|jq '.Items[0].flag.S'|awk -F\" '{print $2}'|sed 's/val-//'
In a Bash script you can get this as a variable value by wrapping command like so:
value=$(<COMMAND>)
Run echo $value
to see who is awesome :-)