How to connect an API Gateway to Lambda in CloudFormation

To connect an API Gateway to a Lambda function using CloudFormation, you can follow these steps: Define your API Gateway and Lambda function resources in your CloudFormation template. Here’s an example: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Resources: MyLambdaFunction: Type: AWS::Lambda::Function Properties: FunctionName: MyLambdaFunction Runtime: python3.8 Handler: index.handler Code: S3Bucket: my-lambda-code-bucket S3Key: lambda-code.zip MyApiGateway: Type: AWS::ApiGateway::RestApi Properties: Name: MyApiGateway Create a resource of type AWS::ApiGateway::Resource to define the resource path for your API Gateway: 1 2 3 4 5 6 MyApiGatewayResource: Type: AWS::ApiGateway::Resource Properties: RestApiId: !

Create DynamoDB Table & Add Items using Python 3 from Lambda

To create a DynamoDB table and add items to it using Python 3 from AWS Lambda, you can use the AWS SDK for Python, also known as Boto3. Here’s a step-by-step guide: Set up your AWS environment: Install Boto3 by running pip install boto3 in your local development environment. Set up your AWS credentials and configure your AWS CLI or environment variables. You can find detailed instructions in the AWS documentation.

How to create a Site-to-Site VPN in Boto3 Python

To create a site-to-site VPN using the Boto3 library in Python, you can utilize the boto3.client('ec2') client to interact with the AWS EC2 service. Here’s an example code snippet to create a site-to-site VPN: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 import boto3 ec2_client = boto3.client('ec2') # Create VPN Gateway vpn_gateway_response = ec2_client.

How to create a Site-to-Site VPN in Terraform

To create a site-to-site VPN using Terraform, you can use the aws_vpn_gateway and aws_vpn_connection resources from the AWS provider. Here’s an example Terraform configuration to create a site-to-site VPN: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 resource "aws_vpn_gateway" "vpn_gateway" { vpc_id = "<VPC_ID>" tags = { Name = "SiteToSiteVPN" } } resource "aws_vpn_connection" "vpn_connection" { customer_gateway_id = "<CUSTOMER_GATEWAY_ID>" vpn_gateway_id = aws_vpn_gateway.

How to create a Site-to-Site VPN in CloudFormation

To create a site-to-site VPN (Virtual Private Network) using AWS CloudFormation, you can use the AWS::EC2::VPNGateway and AWS::EC2::VPNConnection resources. Here’s an example CloudFormation template to create a site-to-site VPN: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 AWSTemplateFormatVersion: '2010-09-09' Resources: VpnGateway: Type: AWS::EC2::VPNGateway Properties: Type: ipsec.1 Tags: - Key: Name Value: SiteToSiteVPN VpnConnection: Type: AWS::EC2::VPNConnection Properties: Type: ipsec.

How to AWS sts assume role in one command - without jq

The issue - what it takes to assume a role To assume an AWS role in the CLI, you will have to do something like this: 1 aws sts assume-role --role-arn arn:aws:iam::123456789123:role/myAwesomeRole --role-session-name test --region eu-central-1 This will give you the following output: 1 2 3 4 5 6 7 8 9 10 11 12 { "Credentials": { "AccessKeyId": "someAccessKeyId", "SecretAccessKey": "someSecretAccessKey", "SessionToken": "someSessionToken", "Expiration": "20203-01-02T06:52:13+00:00" }, "AssumedRoleUser": { "AssumedRoleId": "idOfTheAssummedRole", "Arn": "theARNOfTheRoleIWantToAssume" } } But then you will have to manually copy and paste the values of AccessKeyId, SecretAccessKey and SessionToken in a bunch of exports like this:

How to create a Lambda in CloudFormation

You can create a Lambda in CloudFormation as follows: Option 1 - Inline code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Resources: MyLambdaFunction: Type: AWS::Lambda::Function Properties: FunctionName: MyLambdaFunction Runtime: python3.8 Handler: index.lambda_handler Code: ZipFile: | import json def lambda_handler(event, context): # Your Lambda function code here return { 'statusCode': 200, 'body': json.dumps('Hello from Lambda!') } Role: !GetAtt MyLambdaExecutionRole.Arn In this example, instead of specifying the S3Bucket and S3Key properties under the Code section, you use the ZipFile property to provide the actual code as a multiline string.

How to create a Lambda in Terraform

To create an AWS Lambda function using Terraform, you need to define the necessary resources in a Terraform configuration file. Here’s an example of how you can create a Lambda function using Terraform: Option 1 - Seperate Lambda Source Create a new directory for your Terraform configuration and navigate to it in your terminal. Create a new file with a .tf extension, such as lambda.tf, and open it in a text editor.

How to create a Bastion server in Terraform

To create a Bastion server using Terraform, you need to define the necessary resources in a Terraform configuration file. Here’s an example of how you can create a Bastion server using Terraform: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 # Define the security group resource "aws_security_group" "bastion_sg" { name = "bastion-security-group" description = "Bastion Security Group" ingress { from_port = 22 to_port = 22 protocol = "tcp" cidr_blocks = ["0.

How to create a Bastion server in CloudFormation

To create a Bastion server using AWS CloudFormation, you need to define the necessary resources in a CloudFormation template. Here’s an example of how you can create a Bastion server using CloudFormation: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 AWSTemplateFormatVersion: "2010-09-09" Resources: BastionSecurityGroup: Type: AWS::EC2::SecurityGroup Properties: GroupDescription: Bastion Security Group SecurityGroupIngress: - IpProtocol: tcp FromPort: 22 ToPort: 22 CidrIp: 0.

How to you create a Cross Account Role in Terraform

To create a cross-account role in Terraform, you need to perform the following steps: 1. Define the IAM role Define the IAM role in the Terraform configuration 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 resource "aws_iam_role" "cross_account_role" { name = "CrossAccountRole" assume_role_policy = <<EOF { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::<ACCOUNT_ID>:root" }, "Action": "sts:AssumeRole" } ] } EOF } In the assume_role_policy section, replace <ACCOUNT_ID> with the AWS account ID of the target account that will assume this role.

How to you create a Cross Account Role in CloudFormation

To create a cross-account role in CloudFormation, you can follow these steps: 1. Create a CloudFormation template Create a new CloudFormation template in YAML or JSON format. This template will define the resources, including the cross-account role, that you want to create. 2. Define the cross-account role Within your CloudFormation template, define the cross-account role using the AWS::IAM::Role resource type. Specify the necessary properties such as RoleName, AssumeRolePolicyDocument, and ManagedPolicyArns.

How to create Public and Private Subnets in CloudFormation

To create public and private subnets in AWS CloudFormation, you can use the AWS CloudFormation Template Language (CFT) to define your network configuration. Here’s an example CloudFormation template that demonstrates how to create public and private subnets within a Virtual Private Cloud (VPC) in AWS: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Resources: MyVPC: Type: AWS::EC2::VPC Properties: CidrBlock: 10.

How to create Public and Private Subnets in Terraform

To create public and private subnets in Terraform, you can use the AWS provider to define your network configuration. Here’s an example configuration that demonstrates how to create public and private subnets within a Virtual Private Cloud (VPC) in AWS: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 # Define your AWS provider configuration provider "aws" { region = "us-west-2" # Update with your desired region } # Create the VPC resource "aws_vpc" "my_vpc" { cidr_block = "10.

Create Internet Gateway & Assign to EC2 in CloudFormation

To create an Internet Gateway and associate it with an EC2 instance using AWS CloudFormation, you can follow these steps: Step 1: Create a CloudFormation template Create a new YAML or JSON file with a .yaml or .json extension (e.g., template.yaml), and add the following contents: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 AWSTemplateFormatVersion: "2010-09-09" Resources: MyVPC: Type: AWS::EC2::VPC Properties: CidrBlock: 10.

Create Internet Gateway & Assign to EC2 in Terraform

To create an Internet gateway and assign it to an EC2 instance using Terraform, you can follow these steps: Step 1: Set up your Terraform environment Install Terraform: Download and install Terraform from the official website (https://www.terraform.io/downloads.html) based on your operating system. Configure AWS credentials: Set up your AWS access key and secret access key as environment variables or use an AWS profile configured on your system. Step 2: Create a Terraform configuration file Create a new file with a .

How to configure Terraform to use Local Providers from Nexus

If your organization has blocked registry.terraform.io and has instead downloaded the provider binaries to Nexus, then you can do the following to still make your Terraform execute correctly. Step 1 - Download the Required Providers In our example, we need the following providers: AWS Archive These commands below are running directly from the pipeline that executes the Terraform: 1 2 3 4 5 6 7 8 9 10 11 # Download the providers from the Nexus repository - curl -u ${Nexus_REPO_USER}:${Nexus_REPO_PASS} -o terraform-provider-aws4.

[Solved] Fargate Can't Read Secrets from Secret Manager

If you’re running a Fargate task and it’s not able to read secrets from AWS Secret Manager, there are a few things you can check: Verify that the Fargate task has the correct IAM permissions to access the secret. You need to grant the task the secretsmanager:GetSecretValue permission for the specific secret that it needs to access. You can do this by adding the necessary permission to the task execution role, or by creating a separate IAM role and attaching it to the task.

Golang vs Python: The Ultimate Battle in DevOps

In the world of DevOps, two programming languages are often pitted against each other: Golang and Python. Both languages have their own strengths and weaknesses, and choosing the right one for your DevOps needs can be a tough decision. In this blog post, we will take a closer look at Golang and Python, and compare their capabilities in the DevOps landscape. Golang Golang is a language that has gained immense popularity in recent years, especially in the field of DevOps.

Why DevOps and Python are Amazing Together

In today’s software development world, DevOps and Python are two of the most essential elements for building high-quality software. DevOps has transformed the way software is developed, tested, and deployed, while Python has become a popular programming language for automation and scripting. The combination of DevOps and Python is particularly powerful because it provides developers with the necessary tools to automate, test, and deploy software efficiently. Here are some of the reasons why DevOps and Python are such a great match: