Vern  Greenholt

Vern Greenholt

1595500920

AWS Lambda — Managing EC2 Instances

We created an AWS Lambda function that creates an EC2 instance in my previous article. Today we will gonna talk about How can we manage EC2 Instance with AWS Lambda.

we will write a Lambda function that will manage an EC2 instance. This Lambda function will be written in Python using the Boto3 library as well as Javascript. We will also create a custom Lambda execution policy for our IAM role. When we’re done, we will be able to manage EC2 instances via the AWS Lambda function.

Let’s Move on the AWS Management Console

Let’s navigate to AWS Identity and Access Management (IAM) to create a role for our AWS Lambda function.

Select Role > Create Role > Select AWS service > Select Lambda As a use case and create a role with the below policy.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "logs:CreateLogStream",
                "logs:PutLogEvents"
            ],
            "Resource": "arn:aws:logs:*:*:*"
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": [
                "ec2:*"
            ],
            "Resource": "*"
        },
        {
            "Sid": "VisualEditor2",
            "Effect": "Allow",
            "Action": "logs:CreateLogGroup",
            "Resource": "arn:aws:logs:*:*:*"
        }
    ]
}

Let’s Move on the AWS Lambda

  1. In the Lambda console, choose to Create function.
  2. Choose Author from scratch.
  3. Under Basic information, add the following:
    • For Function name, enter a name that identifies it as the function used to Stop your EC2 instances. For example, “StartEC2Instances”.
    • For Runtime, choose Python 3.7 or Node.js.
    • Under Permissions, expand Choose or create an execution role.
    • Under the Execution role, choose to use an existing role.
    • Under the Existing role, choose the IAM role that you created.

4. Choose to Create a function.

5. Copy this code, and then under Function code, paste it into the editor panel in the code editor (lambda_function).

This code Starts the EC2 instances that you identify.

#devops #aws-lambda #aws #ec2

What is GEEK

Buddha Community

AWS Lambda — Managing EC2 Instances
Rory  West

Rory West

1621745280

Create EC2 instance from AWS Console

What is EC2 Instance?

Secure and resizable compute capacity in the cloud.

Amazon Elastic Compute Cloud ( Amazon EC2) is a web service that provides secure, resizable compute capacity in the cloud. It is designed to make web-scale cloud computing easier for developers.

In this article let us see how to create On-demand EC2 instance from Console.

#create-ec2-instance #aws-ec2-instance #ec2-instance #amazon-web-services #aws

AWS Lambda Vs EC2 | Serverless Vs EC2 | EC2 Alternatives

In this video we are going to learn the differences between ec2 vs lambda by going over:

  1. What is Serverless and what is EC2
  2. Environment, Use Case difference between lambda and ec2
  3. Learn how differently EC2 and Lambda scale
  4. Do Cost comparison lambda vs ec2 for couple cases
  5. Finally we are going to look at some EC2 alternatives and end with parting words.

#aws #lambda #ec2 #serverless #aws lambda

Vern  Greenholt

Vern Greenholt

1595500920

AWS Lambda — Managing EC2 Instances

We created an AWS Lambda function that creates an EC2 instance in my previous article. Today we will gonna talk about How can we manage EC2 Instance with AWS Lambda.

we will write a Lambda function that will manage an EC2 instance. This Lambda function will be written in Python using the Boto3 library as well as Javascript. We will also create a custom Lambda execution policy for our IAM role. When we’re done, we will be able to manage EC2 instances via the AWS Lambda function.

Let’s Move on the AWS Management Console

Let’s navigate to AWS Identity and Access Management (IAM) to create a role for our AWS Lambda function.

Select Role > Create Role > Select AWS service > Select Lambda As a use case and create a role with the below policy.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "logs:CreateLogStream",
                "logs:PutLogEvents"
            ],
            "Resource": "arn:aws:logs:*:*:*"
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": [
                "ec2:*"
            ],
            "Resource": "*"
        },
        {
            "Sid": "VisualEditor2",
            "Effect": "Allow",
            "Action": "logs:CreateLogGroup",
            "Resource": "arn:aws:logs:*:*:*"
        }
    ]
}

Let’s Move on the AWS Lambda

  1. In the Lambda console, choose to Create function.
  2. Choose Author from scratch.
  3. Under Basic information, add the following:
    • For Function name, enter a name that identifies it as the function used to Stop your EC2 instances. For example, “StartEC2Instances”.
    • For Runtime, choose Python 3.7 or Node.js.
    • Under Permissions, expand Choose or create an execution role.
    • Under the Execution role, choose to use an existing role.
    • Under the Existing role, choose the IAM role that you created.

4. Choose to Create a function.

5. Copy this code, and then under Function code, paste it into the editor panel in the code editor (lambda_function).

This code Starts the EC2 instances that you identify.

#devops #aws-lambda #aws #ec2

Tia  Gottlieb

Tia Gottlieb

1595508360

AWS Lambda — Launch EC2 Instances

There are a variety of situations where having a microservice available that can manage (Create, start, stop or terminate)EC2 instances at will can be handy. In this article, we are going to see how we can use an AWS Lambda to do such a thing on demand without using any extra servers or instances at all.

we will write a Lambda function that will create an EC2 instance. This Lambda function will be written in Python using the Boto3 library. We will also create a custom Lambda execution policy for our IAM role. When we’re done, we will be able to log in to the new EC2 instance via SSH.

Let’s Move on the AWS Management Console

Let’s navigate to AWS Identity and Access Management (IAM) to create a role for our AWS Lambda function.

Select Role > Create Role > Select AWS service > Select Lambda As a use case and create a role with the below policy.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "logs:CreateLogStream",
                "logs:PutLogEvents"
            ],
            "Resource": "arn:aws:logs:*:*:*"
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": [
                "ec2:*"
            ],
            "Resource": "*"
        },
        {
            "Sid": "VisualEditor2",
            "Effect": "Allow",
            "Action": "logs:CreateLogGroup",
            "Resource": "arn:aws:logs:*:*:*"
        }
    ]
}

Let’s Move on the AWS Lambda

  1. Select Functions > Create Function
  2. Enter the name of your lambda function.
  3. Select python as a runtime language.
  4. Click on **Choose or create an execution role **> SelectUse an existing role.
  5. Click Create Function.
  6. Navigate to AWS Lambda
  7. Select Functions > Create Function
  8. Click on **Choose or create an execution role**> SelectUse an existing role .

#aws #automation-testing #aws-lambda #devops #aws-ec2

Camron  Shields

Camron Shields

1597954680

Amazon EC2 evolution— How Nitro changed everything and Instance type deep dive

Introduction

For those new to EC2, EC2 offers auto-scalable instances with compute, memory, storage and networking, deployable in multiple Availability zones/Regions while targetable by a load balancer along with management / administration tools such as AWS Systems Manager and AWS License Manager. EC2 instances are available under multiple purchase options such as SpotOn-DemandReserved and Savings Plan. It offers a broad choice of processors such as Intel, AMD and Amazon’s very own ARM-based Graviton processors. EC2 also allows the possibility of using Application Specific Integrated-Circuit (ASICs) and Field Programmable Gate-Array (FPGAs).

For those new to terms like ASIC and FPGA, they provide an alternate way to compute than CPU and GPU. Unlike CPU and GPU, which have a predefined instruction set and general purpose or parallel computing optimized , ASICs are dedicated, custom designed and optimized for one specific function (for e.g. bitcoin mining) whereas FPGAs are, as their name suggests, programmable digital logic cells. The hardware can be reprogrammed / repurposed to different workloads. Neither ASICs nor FPGAs have a predefined instruction set.

A very short history

Amazon launched EC2 with one instance type, m1, in the year 2006. This machine offered 1.7 GHz of CPU, 1.75 GB of RAM, 160 GB of disk and 250 Mbps of network bandwidth. This has evolved to 300+ instance types as of July 2020.

EC2 currently offers instance with upto 4.0GHz of CPU(z1d), 24576 GB / 24 TB of RAM(u-24tb1.metal), 48 TB of disk (d2.8xlarge) and 100 Gbps of Network bandwidth (High-Memory instances). Nitro turbo-charged this evolution in 2017 at which time “only” 42 instance types were available. It allowed new CPU architectures (ARM, AMD), bare metal offerings, 100 Gbps networking, EFA etc. So what exactly is Nitro?

Nitro — in english

Nitro refers to a whole fleet of changes, hardware and software, brought about in order to improve two important aspects of the infrastructure: performance and security. The basic idea is about offloading functions that are generally performed in a hypervisor stack to separate dedicated hardware / software component. Before Nitro — Networking, Storage, Security etc. were part of the hypervisor stack and contributed to about 30% of resource consumption that could not be used by customer instances.

Image for post

With Nitro architecture, these components are moved out of the hypervisor stack, allowing for better resource consumption / performance and more controlled security.

#aws #ec2 #ec2-instance #nitro #aws-ec2