Implement a Lambda function to run commands via SSM
I have a run document in ssm to install some agents on the server.
Now, I wanted to automate this task by running these documents whenever a new instance is launched.
I want to achieve this through aws lambda(script to implement run commands upon launch of a new instance)
Any help would be appreciated !!!
amazon-web-services aws-lambda ssm
add a comment |
I have a run document in ssm to install some agents on the server.
Now, I wanted to automate this task by running these documents whenever a new instance is launched.
I want to achieve this through aws lambda(script to implement run commands upon launch of a new instance)
Any help would be appreciated !!!
amazon-web-services aws-lambda ssm
add a comment |
I have a run document in ssm to install some agents on the server.
Now, I wanted to automate this task by running these documents whenever a new instance is launched.
I want to achieve this through aws lambda(script to implement run commands upon launch of a new instance)
Any help would be appreciated !!!
amazon-web-services aws-lambda ssm
I have a run document in ssm to install some agents on the server.
Now, I wanted to automate this task by running these documents whenever a new instance is launched.
I want to achieve this through aws lambda(script to implement run commands upon launch of a new instance)
Any help would be appreciated !!!
amazon-web-services aws-lambda ssm
amazon-web-services aws-lambda ssm
asked Nov 23 '18 at 5:03
AKSHAY NARAYAN
1
1
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Unfortunately this is a very broad questions, one that could not possibly be answered simply.
I would first suggest you decide which language you wish to write your lambda function in currently there are .NET, python, Node.js, Java and Go.
Node.js is a fairly easy language to start with as it's well supported and you can write it within the inline AWS code editor.
I would suggest looking at the template Node.js lambda functions that aws provides when creating a new lambda function within the console. This will help you see how that could be put together and the various ways that may be used. If you get the hang of these and find them easy enough to understand then you can look at the Node.js SSM api which should be available by default in the lambda runtime and try out running a few commands.
Of course if you're not competent in Node.js and primarily use another language then that's an entirely different question.
There are many resources and examples online for writing lambdas that can be found very easily.
add a comment |
Use a cloudwatch rule for this.
Create a cloudwatch rule for EC2 Instance State-change Notification
and running
state. Use lambda as the target and invoke the SSM command from lambda (via API) on the instance. The event will have the details you need like instance id. Hope you are familiar with AWS API's and how to use it. You will need a proper IAM role for your Lambda for this to work. Also, remember Cloudwatch events are region specific and can only invoke a lambda in the same region.
1
Figured out about AWS-SSM State Manager. It does the job without having to write any script, creating the association runs the ssm document to install agents at the time of instance launch
– AKSHAY NARAYAN
Dec 5 '18 at 13:18
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%2f53440891%2fimplement-a-lambda-function-to-run-commands-via-ssm%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Unfortunately this is a very broad questions, one that could not possibly be answered simply.
I would first suggest you decide which language you wish to write your lambda function in currently there are .NET, python, Node.js, Java and Go.
Node.js is a fairly easy language to start with as it's well supported and you can write it within the inline AWS code editor.
I would suggest looking at the template Node.js lambda functions that aws provides when creating a new lambda function within the console. This will help you see how that could be put together and the various ways that may be used. If you get the hang of these and find them easy enough to understand then you can look at the Node.js SSM api which should be available by default in the lambda runtime and try out running a few commands.
Of course if you're not competent in Node.js and primarily use another language then that's an entirely different question.
There are many resources and examples online for writing lambdas that can be found very easily.
add a comment |
Unfortunately this is a very broad questions, one that could not possibly be answered simply.
I would first suggest you decide which language you wish to write your lambda function in currently there are .NET, python, Node.js, Java and Go.
Node.js is a fairly easy language to start with as it's well supported and you can write it within the inline AWS code editor.
I would suggest looking at the template Node.js lambda functions that aws provides when creating a new lambda function within the console. This will help you see how that could be put together and the various ways that may be used. If you get the hang of these and find them easy enough to understand then you can look at the Node.js SSM api which should be available by default in the lambda runtime and try out running a few commands.
Of course if you're not competent in Node.js and primarily use another language then that's an entirely different question.
There are many resources and examples online for writing lambdas that can be found very easily.
add a comment |
Unfortunately this is a very broad questions, one that could not possibly be answered simply.
I would first suggest you decide which language you wish to write your lambda function in currently there are .NET, python, Node.js, Java and Go.
Node.js is a fairly easy language to start with as it's well supported and you can write it within the inline AWS code editor.
I would suggest looking at the template Node.js lambda functions that aws provides when creating a new lambda function within the console. This will help you see how that could be put together and the various ways that may be used. If you get the hang of these and find them easy enough to understand then you can look at the Node.js SSM api which should be available by default in the lambda runtime and try out running a few commands.
Of course if you're not competent in Node.js and primarily use another language then that's an entirely different question.
There are many resources and examples online for writing lambdas that can be found very easily.
Unfortunately this is a very broad questions, one that could not possibly be answered simply.
I would first suggest you decide which language you wish to write your lambda function in currently there are .NET, python, Node.js, Java and Go.
Node.js is a fairly easy language to start with as it's well supported and you can write it within the inline AWS code editor.
I would suggest looking at the template Node.js lambda functions that aws provides when creating a new lambda function within the console. This will help you see how that could be put together and the various ways that may be used. If you get the hang of these and find them easy enough to understand then you can look at the Node.js SSM api which should be available by default in the lambda runtime and try out running a few commands.
Of course if you're not competent in Node.js and primarily use another language then that's an entirely different question.
There are many resources and examples online for writing lambdas that can be found very easily.
answered Nov 23 '18 at 5:22
David Rees
1,9361522
1,9361522
add a comment |
add a comment |
Use a cloudwatch rule for this.
Create a cloudwatch rule for EC2 Instance State-change Notification
and running
state. Use lambda as the target and invoke the SSM command from lambda (via API) on the instance. The event will have the details you need like instance id. Hope you are familiar with AWS API's and how to use it. You will need a proper IAM role for your Lambda for this to work. Also, remember Cloudwatch events are region specific and can only invoke a lambda in the same region.
1
Figured out about AWS-SSM State Manager. It does the job without having to write any script, creating the association runs the ssm document to install agents at the time of instance launch
– AKSHAY NARAYAN
Dec 5 '18 at 13:18
add a comment |
Use a cloudwatch rule for this.
Create a cloudwatch rule for EC2 Instance State-change Notification
and running
state. Use lambda as the target and invoke the SSM command from lambda (via API) on the instance. The event will have the details you need like instance id. Hope you are familiar with AWS API's and how to use it. You will need a proper IAM role for your Lambda for this to work. Also, remember Cloudwatch events are region specific and can only invoke a lambda in the same region.
1
Figured out about AWS-SSM State Manager. It does the job without having to write any script, creating the association runs the ssm document to install agents at the time of instance launch
– AKSHAY NARAYAN
Dec 5 '18 at 13:18
add a comment |
Use a cloudwatch rule for this.
Create a cloudwatch rule for EC2 Instance State-change Notification
and running
state. Use lambda as the target and invoke the SSM command from lambda (via API) on the instance. The event will have the details you need like instance id. Hope you are familiar with AWS API's and how to use it. You will need a proper IAM role for your Lambda for this to work. Also, remember Cloudwatch events are region specific and can only invoke a lambda in the same region.
Use a cloudwatch rule for this.
Create a cloudwatch rule for EC2 Instance State-change Notification
and running
state. Use lambda as the target and invoke the SSM command from lambda (via API) on the instance. The event will have the details you need like instance id. Hope you are familiar with AWS API's and how to use it. You will need a proper IAM role for your Lambda for this to work. Also, remember Cloudwatch events are region specific and can only invoke a lambda in the same region.
answered Nov 23 '18 at 9:04
titogeo
1,4451833
1,4451833
1
Figured out about AWS-SSM State Manager. It does the job without having to write any script, creating the association runs the ssm document to install agents at the time of instance launch
– AKSHAY NARAYAN
Dec 5 '18 at 13:18
add a comment |
1
Figured out about AWS-SSM State Manager. It does the job without having to write any script, creating the association runs the ssm document to install agents at the time of instance launch
– AKSHAY NARAYAN
Dec 5 '18 at 13:18
1
1
Figured out about AWS-SSM State Manager. It does the job without having to write any script, creating the association runs the ssm document to install agents at the time of instance launch
– AKSHAY NARAYAN
Dec 5 '18 at 13:18
Figured out about AWS-SSM State Manager. It does the job without having to write any script, creating the association runs the ssm document to install agents at the time of instance launch
– AKSHAY NARAYAN
Dec 5 '18 at 13:18
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f53440891%2fimplement-a-lambda-function-to-run-commands-via-ssm%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