I'm trying to synchronize aws iot and lorawan. Following the instructions in the official documentation , everything works out well.
But there is used for deployment elastic beanstalk which raises the instance ec2 where the script for synchronization is executed.
But I do not need eb. I want to run only the script
I downloaded all this script separately and am trying to run. This causes an error.
Based on the cloudformation template, this script uses these variables.
I do not understand where elasticbeanstalk stores all these variables. Someone can suggest this or point to another solution for running the script?
Related
I recently started getting into the devops side of things and am currently working with Terraform and AWS ECS to setup a simple web server host my web applications.
Using my current Terraform config I can see my cluster being created with a service that has my task definition. I can't figure out how to run the tasks required to launch the webserver from Terraform. I can only see the capability to create the task definitions and services, but not run them. I am very new to both these technologies so I fear I might be missing something simple.
The setup I used is from an example I found online that I tried to follow.
TL;DR: I can create services using Terraform but can't seem to figure out how to run them.
You need define an "aws_ecs_service" resource in Terraform and in there define how many instances of your task you want running. In the example you link, that is done in the main.tf file here.
There is no way you can run the task from terraform except running the external script or aws-cli from the local-exec provisioner.
I can see a generic way of starting an EC2 from lambda in Start and Stop Instances at Scheduled Intervals Using Lambda and CloudWatch.
Suppose I use that method to start an EC2, and suppose the AMI is a windows server 2019 customised to have a .bat file on the desktop, and also suppose I'm using a python lambda.
How can I execute this batch file from the lambda? (i.e. just as though someone had RDP'd into the instance and double-clicked on it)
Note: To be very clear, basically I want to start the EC2 using the method given in the AWS docs (above), and right after the instance has started, to run the batch file that will be sitting on the instance's desktop
I think you have a few concepts mixed together.
AWS Lambda functions run on the Lambda service, without having to use Amazon EC2 instances. This is what makes them "serverless".
If you have a batch file on an Amazon EC2 instance, you would presumably want to run that batch file on the EC2 instance itself, without involving Lambda (since you have got a server).
If you wish to run a script on an EC2 instance when it launches for the first time, you can provide a PowerShell or Command-Line script via the User Data field. Software on the AMI will automatically execute this script the first time that the instance starts.
This script could do all the work itself, or it could simply call another script that is stored on the disk. Some people use the script to download another script from a repository (eg Amazon S3 or GitHub) and then execute the downloaded script.
For more information, see: Running Commands on Your Windows Instance at Launch - Amazon Elastic Compute Cloud
If the Amazon EC2 instance is already running and you wish to trigger a script to execute, you can use the AWS Systems Manager Run Command. This works by having an agent on the instance which can be remotely triggered, thereby running scripts without having to login to the instance.
I am working to extend this solution https://github.com/adieuadieu/serverless-chrome to my needs.
I am using serverless (on my laptop with Debian 9) to deploy it to AWS Lambda. I would like to use AWS-Sam-local https://github.com/awslabs/aws-sam-local to run it locally for developing.
I would like to use AWS-Sam-local because I believe that there is difference between running this solution via serverless webpack serve --function run and sam local start-api. The difference I think, is event object which I want to make contain POST or binary data (multipart files transfer). For that I have to allow binary transfer via API Gateway.
But correct me if I am wrong because I am totally green in the AWS and Serverless field and this is my first time with this technologies.
The problem I get is aws-sam-local needs the CloudFormation template to know how to run serverless-chrome project. If I make deploy to AWS and go to CloudFormation Console I can copy that template after selecting it in "Stacks" table and clicking "Template" tab. Then I use cfn-flip to convert JSON into YAML. In the end I got template.yml, but running sam local start-api gives me error:
2017/10/06 11:03:23 Connected to Docker 1.32
ERROR: No Serverless functions were found in your SAM template.
Please tell me what to do to make serverless-chrome run locally as it would run on AWS Lambda.
The templates Serverless uses to deploy are available in two places:
Remotely, in the S3 deployment bucket
locally, in .serverless/
I have a powershell script in the .ebextensions folder but its not executing. It used to work but suddenly has stopped working and there have been no changes to elastic beanstalk or the scripts that i know off. I have two instance running under elastic beanstalk and if I log into one and then deploy my package it doesnt take the instance down. I can literally watch the service (IIS Rest service) files being updated.
Elastic Beanstalk is configured for autoscaling min 2 instances max 4. I've tried doing a deploy though the AWS Elastic Beanstalk console but no joy.
Does it need to actually take the instances down in order to run the scripts? I find it odd that it can update the service without stopping the instance.
Also do .ebextension scripts not execute against running instances? is there a way to force it to execute?
What else can I check to see why the ebextensions are not being picked up?
Thanks
It's working now. My ebextensions script was not formatted properly, i.e. didn't have the necessary indentations that YAML requires so the commands where being ignored. However no error was raised by EB.
Another problem is that eb cli uses git to bundle your app, which means that you need to perform a commit so that all changes are properly bundled.
Until I get my changes right, I keep doing git add & git commit --amend all the time...
Using the AWS SDK, when using the RunInstances method to programmatically start up an EC2 instance, what is the proper method for automatically deploying a specific script or setup of software to the instance once it's started? AWS CodeDeploy? Or is that overkill?
Essentially I want to:
Programmatically start up an On-Demand instance (I got this figured out)
After startup, automatically deploy some basic Node.js scripts to the server
Automatically execute those scripts.
All of the steps need to be automatic. You can assume the Node.js scripts are in some accessible Git repo hosted somewhere
What is the best and most simple straightforward way to accomplish this?
The Instance User Data can be a simple script that does that, check out http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html