Cloudformation: User-data in EC2 as well as in Launch Templateunable to pass the user-data to the ec2 ubuntu instancebash causes invalid json for ec2 cli requestUnable to update .bashrc file from AWS CloudFormation scriptAWS - cfn-init not creating a fileWhy is the script in the DataUser section of my Ubuntu EC2 instance not running? I am using Cloudformationappending/prepending to userdata passed to cloudformation?Cfn-hup does not run on updating the StackFailing to create AWS EC2 instance sbin/plymouthd: No such filehow to tell cloud formation init it shall use a specific repository by installing yum packagesuser data is not running at launch aws ec2
Can a Beholder use rays in melee range?
Black-and-white film where monster/alien gets fried
How current works
What F1 in name of seeds/varieties means?
Can a non-EU citizen travel within schengen zone freely without passport?
Future enhancements for the finite element method
How to properly maintain eye contact with people that have distinct facial features?
Plot exactly N bounce of a ball
Were pen cap holes designed to prevent death by suffocation if swallowed?
Could I be denied entry into Ireland due to medical and police situations during a previous UK visit?
Terminology about G- simplicial complexes
Employer demanding to see degree after poor code review
Is a post-climate apocolypse city in which many or most insects have disappeared realistic?
Is this story about US tax office reasonable?
How do you deal with an abrupt change in personality for a protagonist?
Is CD audio quality good enough for the final delivery of music?
How do I subvert the tropes of a train heist?
Is there any use case for the bottom type as a function parameter type?
Yandex Programming Contest: Alarms
Is there an evolutionary advantage to having two heads?
Draw a checker pattern with a black X in the center
Crossing US border with music files I'm legally allowed to possess
Is there an explanation for Austria's Freedom Party virtually retaining its vote share despite recent scandal?
How does apt-get work, in detail?
Cloudformation: User-data in EC2 as well as in Launch Template
unable to pass the user-data to the ec2 ubuntu instancebash causes invalid json for ec2 cli requestUnable to update .bashrc file from AWS CloudFormation scriptAWS - cfn-init not creating a fileWhy is the script in the DataUser section of my Ubuntu EC2 instance not running? I am using Cloudformationappending/prepending to userdata passed to cloudformation?Cfn-hup does not run on updating the StackFailing to create AWS EC2 instance sbin/plymouthd: No such filehow to tell cloud formation init it shall use a specific repository by installing yum packagesuser data is not running at launch aws ec2
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
It seems like EC2 User-Data takes preference here and never executes Launch Template User-Data.
if I remove User-Data from EC2 it executes LaunchTemplate User-Data without any problem.
The AMI id being used is of CentOS 7.
How can i achieve to run both User-Data in some order.
I have already played around with cloudformation a lot and looked at forums.
"Resources":
"BSLaunchTemplate":
"Type": "AWS::EC2::LaunchTemplate",
"Properties":
"LaunchTemplateName": "BroadSoftLaunchTemplate2",
"LaunchTemplateData":
"KeyName": "haystackaccess",
"ImageId": "ami-014b38e758721be30",
"InstanceType": "t2.medium",
"SecurityGroupIds":["sg-e0b92fa7"],
"UserData":
"Fn::Base64":
"Fn::Join":["", [
"#!/bin/bash n",
"yum update -y n",
"yum –y install epel-release n",
"yum -y install python-pip n",
"pip install pystache n",
"pip install argparse n",
"pip install python-daemon n",
"pip install requests n",
"yum install -y https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.amzn1.noarch.rpm n",
"echo UD_OF_LT_1 >> /var/log/user-data.log n",
"echo UD_OF_LT_2 >> /var/log/user-data.log n",
"echo UD_OF_Lt_3 >> /var/log/user-data.log n"
]
]
,
"primaryec2":
"Type": "AWS::EC2::Instance",
"Properties":
"LaunchTemplate":
"LaunchTemplateId":"Ref":"BSLaunchTemplate",
"Version":"1",
,
"Tags": [
"Key": "Name",
"Value": "Network Server"
],
"UserData":
"Fn::Base64":
"Fn::Join": ["",[
"#!/bin/bash n",
"echo UD_OF_EC2_1 >> /var/log/user-data.log n",
"echo UD_OF_EC2_2 >> /var/log/user-data.log n",
"echo UD_OF_EC2_3 >> /var/log/user-data.log n"
]
]
amazon-web-services amazon-cloudformation
add a comment |
It seems like EC2 User-Data takes preference here and never executes Launch Template User-Data.
if I remove User-Data from EC2 it executes LaunchTemplate User-Data without any problem.
The AMI id being used is of CentOS 7.
How can i achieve to run both User-Data in some order.
I have already played around with cloudformation a lot and looked at forums.
"Resources":
"BSLaunchTemplate":
"Type": "AWS::EC2::LaunchTemplate",
"Properties":
"LaunchTemplateName": "BroadSoftLaunchTemplate2",
"LaunchTemplateData":
"KeyName": "haystackaccess",
"ImageId": "ami-014b38e758721be30",
"InstanceType": "t2.medium",
"SecurityGroupIds":["sg-e0b92fa7"],
"UserData":
"Fn::Base64":
"Fn::Join":["", [
"#!/bin/bash n",
"yum update -y n",
"yum –y install epel-release n",
"yum -y install python-pip n",
"pip install pystache n",
"pip install argparse n",
"pip install python-daemon n",
"pip install requests n",
"yum install -y https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.amzn1.noarch.rpm n",
"echo UD_OF_LT_1 >> /var/log/user-data.log n",
"echo UD_OF_LT_2 >> /var/log/user-data.log n",
"echo UD_OF_Lt_3 >> /var/log/user-data.log n"
]
]
,
"primaryec2":
"Type": "AWS::EC2::Instance",
"Properties":
"LaunchTemplate":
"LaunchTemplateId":"Ref":"BSLaunchTemplate",
"Version":"1",
,
"Tags": [
"Key": "Name",
"Value": "Network Server"
],
"UserData":
"Fn::Base64":
"Fn::Join": ["",[
"#!/bin/bash n",
"echo UD_OF_EC2_1 >> /var/log/user-data.log n",
"echo UD_OF_EC2_2 >> /var/log/user-data.log n",
"echo UD_OF_EC2_3 >> /var/log/user-data.log n"
]
]
amazon-web-services amazon-cloudformation
add a comment |
It seems like EC2 User-Data takes preference here and never executes Launch Template User-Data.
if I remove User-Data from EC2 it executes LaunchTemplate User-Data without any problem.
The AMI id being used is of CentOS 7.
How can i achieve to run both User-Data in some order.
I have already played around with cloudformation a lot and looked at forums.
"Resources":
"BSLaunchTemplate":
"Type": "AWS::EC2::LaunchTemplate",
"Properties":
"LaunchTemplateName": "BroadSoftLaunchTemplate2",
"LaunchTemplateData":
"KeyName": "haystackaccess",
"ImageId": "ami-014b38e758721be30",
"InstanceType": "t2.medium",
"SecurityGroupIds":["sg-e0b92fa7"],
"UserData":
"Fn::Base64":
"Fn::Join":["", [
"#!/bin/bash n",
"yum update -y n",
"yum –y install epel-release n",
"yum -y install python-pip n",
"pip install pystache n",
"pip install argparse n",
"pip install python-daemon n",
"pip install requests n",
"yum install -y https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.amzn1.noarch.rpm n",
"echo UD_OF_LT_1 >> /var/log/user-data.log n",
"echo UD_OF_LT_2 >> /var/log/user-data.log n",
"echo UD_OF_Lt_3 >> /var/log/user-data.log n"
]
]
,
"primaryec2":
"Type": "AWS::EC2::Instance",
"Properties":
"LaunchTemplate":
"LaunchTemplateId":"Ref":"BSLaunchTemplate",
"Version":"1",
,
"Tags": [
"Key": "Name",
"Value": "Network Server"
],
"UserData":
"Fn::Base64":
"Fn::Join": ["",[
"#!/bin/bash n",
"echo UD_OF_EC2_1 >> /var/log/user-data.log n",
"echo UD_OF_EC2_2 >> /var/log/user-data.log n",
"echo UD_OF_EC2_3 >> /var/log/user-data.log n"
]
]
amazon-web-services amazon-cloudformation
It seems like EC2 User-Data takes preference here and never executes Launch Template User-Data.
if I remove User-Data from EC2 it executes LaunchTemplate User-Data without any problem.
The AMI id being used is of CentOS 7.
How can i achieve to run both User-Data in some order.
I have already played around with cloudformation a lot and looked at forums.
"Resources":
"BSLaunchTemplate":
"Type": "AWS::EC2::LaunchTemplate",
"Properties":
"LaunchTemplateName": "BroadSoftLaunchTemplate2",
"LaunchTemplateData":
"KeyName": "haystackaccess",
"ImageId": "ami-014b38e758721be30",
"InstanceType": "t2.medium",
"SecurityGroupIds":["sg-e0b92fa7"],
"UserData":
"Fn::Base64":
"Fn::Join":["", [
"#!/bin/bash n",
"yum update -y n",
"yum –y install epel-release n",
"yum -y install python-pip n",
"pip install pystache n",
"pip install argparse n",
"pip install python-daemon n",
"pip install requests n",
"yum install -y https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.amzn1.noarch.rpm n",
"echo UD_OF_LT_1 >> /var/log/user-data.log n",
"echo UD_OF_LT_2 >> /var/log/user-data.log n",
"echo UD_OF_Lt_3 >> /var/log/user-data.log n"
]
]
,
"primaryec2":
"Type": "AWS::EC2::Instance",
"Properties":
"LaunchTemplate":
"LaunchTemplateId":"Ref":"BSLaunchTemplate",
"Version":"1",
,
"Tags": [
"Key": "Name",
"Value": "Network Server"
],
"UserData":
"Fn::Base64":
"Fn::Join": ["",[
"#!/bin/bash n",
"echo UD_OF_EC2_1 >> /var/log/user-data.log n",
"echo UD_OF_EC2_2 >> /var/log/user-data.log n",
"echo UD_OF_EC2_3 >> /var/log/user-data.log n"
]
]
amazon-web-services amazon-cloudformation
amazon-web-services amazon-cloudformation
asked Mar 24 at 8:44
Adarsh ChauhanAdarsh Chauhan
83
83
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
What's the purpose of the primary ec2 instance? I guess you need to run the extra commands on the primary. I mean you could just duplicate the commands - putting them into external bash files might make life a bit easier there. Or create an AMI with the commands you used in the launch template and then use your custom AMI in the primary instance. You might be able to do something with conditionals too, but I think you'd have to be a bit more creative with that since I don't think you can use them directly in the user data itself.
Tim
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55322035%2fcloudformation-user-data-in-ec2-as-well-as-in-launch-template%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
What's the purpose of the primary ec2 instance? I guess you need to run the extra commands on the primary. I mean you could just duplicate the commands - putting them into external bash files might make life a bit easier there. Or create an AMI with the commands you used in the launch template and then use your custom AMI in the primary instance. You might be able to do something with conditionals too, but I think you'd have to be a bit more creative with that since I don't think you can use them directly in the user data itself.
Tim
add a comment |
What's the purpose of the primary ec2 instance? I guess you need to run the extra commands on the primary. I mean you could just duplicate the commands - putting them into external bash files might make life a bit easier there. Or create an AMI with the commands you used in the launch template and then use your custom AMI in the primary instance. You might be able to do something with conditionals too, but I think you'd have to be a bit more creative with that since I don't think you can use them directly in the user data itself.
Tim
add a comment |
What's the purpose of the primary ec2 instance? I guess you need to run the extra commands on the primary. I mean you could just duplicate the commands - putting them into external bash files might make life a bit easier there. Or create an AMI with the commands you used in the launch template and then use your custom AMI in the primary instance. You might be able to do something with conditionals too, but I think you'd have to be a bit more creative with that since I don't think you can use them directly in the user data itself.
Tim
What's the purpose of the primary ec2 instance? I guess you need to run the extra commands on the primary. I mean you could just duplicate the commands - putting them into external bash files might make life a bit easier there. Or create an AMI with the commands you used in the launch template and then use your custom AMI in the primary instance. You might be able to do something with conditionals too, but I think you'd have to be a bit more creative with that since I don't think you can use them directly in the user data itself.
Tim
answered Mar 24 at 21:22
timdtimd
164
164
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55322035%2fcloudformation-user-data-in-ec2-as-well-as-in-launch-template%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown