How to Create CloudFormation with Multiple Files

To create a CloudFormation (CFN) stack with multiple files, you can follow these general steps: Organize your resources: Divide your resources into logical groups or services. For example, you might have separate files for networking, storage, compute, and so on. Create YAML or JSON templates: Create individual YAML or JSON templates for each group or service. Each template will define the resources specific to that group. For example, networking.yaml, storage.yaml, and compute....

June 25, 2023 · 5 min · 919 words · AO

Make EKS cluster private with NodeGroup access

The Theory To make an Amazon Elastic Kubernetes Service (EKS) cluster private and allow nodes to join through a node group, you need to follow a few steps. By default, EKS creates a public cluster, but you can configure it to make it private for enhanced security. Here’s an overview of the process: Create a VPC: Start by creating a Virtual Private Cloud (VPC) in your AWS account if you haven’t already....

June 21, 2023 · 7 min · 1375 words · AO

How do you create an EKS cluster using CloudFormation

The steps to achieve this To create an Amazon Elastic Kubernetes Service (EKS) cluster using CloudFormation, you can follow these steps: Create a CloudFormation template: Start by creating a CloudFormation template in YAML or JSON format. This template will define the resources required for your EKS cluster, including the cluster itself, worker nodes, and other necessary components. Define the EKS cluster resource: Within your CloudFormation template, define an AWS::EKS::Cluster resource. Specify the desired configuration for your EKS cluster, such as the version, name, and role-based access control (RBAC) configuration....

June 17, 2023 · 4 min · 735 words · AO

API Gateway to Inline Lambda in CloudFormation

To connect an API Gateway to an inline 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: Resources: MyApiGateway: Type: AWS::ApiGateway::RestApi Properties: Name: MyApiGateway MyApiGatewayResource: Type: AWS::ApiGateway::Resource Properties: RestApiId: !Ref MyApiGateway ParentId: !GetAtt MyApiGateway.RootResourceId PathPart: myresource MyApiGatewayMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref MyApiGateway ResourceId: !Ref MyApiGatewayResource HttpMethod: GET AuthorizationType: NONE Integration: Type: AWS_PROXY IntegrationHttpMethod: POST Uri: !...

June 15, 2023 · 2 min · 251 words · AO

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: 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: MyApiGatewayResource: Type: AWS::ApiGateway::Resource Properties: RestApiId: !...

June 14, 2023 · 2 min · 248 words · AO

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: 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.1 CustomerGatewayId: <CUSTOMER_GATEWAY_ID> VpnGatewayId: !Ref VpnGateway StaticRoutesOnly: true Tags: - Key: Name Value: SiteToSiteVPNConnection VpnConnectionRoute: Type: AWS::EC2::VPNConnectionRoute Properties: DestinationCidrBlock: <DESTINATION_CIDR_BLOCK> VpnConnectionId: !...

June 10, 2023 · 1 min · 203 words · AO

How to create a Lambda in CloudFormation

You can create a Lambda in CloudFormation as follows: Option 1 - Inline code 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....

June 7, 2023 · 2 min · 367 words · AO

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: AWSTemplateFormatVersion: "2010-09-09" Resources: BastionSecurityGroup: Type: AWS::EC2::SecurityGroup Properties: GroupDescription: Bastion Security Group SecurityGroupIngress: - IpProtocol: tcp FromPort: 22 ToPort: 22 CidrIp: 0.0.0.0/0 VpcId: "your-vpc-id" BastionInstance: Type: AWS::EC2::Instance Properties: ImageId: "your-ami-id" InstanceType: "t2.micro" # Update with the desired instance type SecurityGroupIds: - !...

June 5, 2023 · 2 min · 278 words · AO

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....

June 3, 2023 · 4 min · 641 words · AO

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: Resources: MyVPC: Type: AWS::EC2::VPC Properties: CidrBlock: 10.0.0.0/16 Tags: - Key: Name Value: my-vpc PublicSubnet: Type: AWS::EC2::Subnet Properties: VpcId: !Ref MyVPC CidrBlock: 10.0.0.0/24 AvailabilityZone: us-west-2a Tags: - Key: Name Value: public-subnet PrivateSubnet: Type: AWS::EC2::Subnet Properties: VpcId: !...

June 2, 2023 · 2 min · 237 words · AO