Reputation: 787
I am having cloudformation template which contains two instances with userdata property.
I need to fetch the data from one instance's userdata and pass to another instances userdata.
For example(from below), need to fetch "test" from instance1, and pass to instance2 userdata.
Sample Template:
"instance1": {
"Type": "AWS::EC2::Instance",
"Properties": {
"UserData": {
"Fn::Base64": {
"Fn::Join": [
"",
[
"#!/bin/bash\n",
"set -x\n",
"echo test\n",
]]}}}},
"instance2": {
"Type": "AWS::EC2::Instance",
"Properties": {
"UserData": {
"Fn::Base64": {
"Fn::Join": [
"",
[
"#!/bin/bash\n",
"set -x\n",
//fetch the value
]]}}}},
Upvotes: 5
Views: 1563
Reputation: 35149
Basically you have 2 options:
scp/ssh
directly to another instance and fetch what ever info you need.I would suggest using shared memory for example S3:
On instance 1:
echo "test" > /tmp/myfile
aws s3 cp /tmp/myfile s3://<bucket>/myfile
On instance 2:
aws s3 cp s3://<bucket>/myfile /tmp/myfile
cat /tmp/myfile
Upvotes: 4