Skip to main content

Posts

AWS CloudFormation - Parameters

Greetings! In my previous post, I talked about creating a EC2 instance using CloudFormation. However, it is not that reusable because values are hard coded. Better way to do that is by using Parameters. Parameters is an optional section in the template that enable us to get user input custom values for our template. Let's define a Parameter Parameters section has following form. Parameters: ParameterLogicalID: Type: DataType ParameterProperty: value For an example we can get our security group description as an use input. Parameters: EC2SecurityGroupDescription: Type: String Description: Allow SSH access to the EC2 instance. How to Reference a Parameter The Fn::Ref function can be leveraged to reference parameters. The shorthand for this in YAML is !Ref. !Ref EC2SecurityGroupDescription Parameter Type Parameter types are String, Number, CommaDelimetedList, List, AWS specific parameter like "AWS::EC2::VPC::Id", List, S...

Let's create an EC2 instance with AWS CloudFormation

Greetings In my previous post, I talked briefly about gettings started with CloudFormation. The best way to learn anything is to do practicals. Hence, let's create an EC2 instance with CloudFormation. What are we going to do? Create an EC2 Set the KeyPair Create a SecurityGroup Add SecurityGroup to EC2 Create an EC2 with CloudFormation When we create an EC2 instance with CloudFormation, we can supply the ImageId and InstanceType. We can supply many more properties but for this example, we are not going to use them. Hence all those will default. This means our EC2 instance will be created on default VPC with default configurations. When you manually create an EC2 instance using the AWS console, you can see ImageId for your InstanceType. Copy it and paste it into the CloudFormation file. cfn-ec2.yml AWSTemplateFormatVersion: 2010-09-09 MyEC2Instance: Type: AWS::EC2::Instance Properties: InstanceType: t2.micro ImageId: ami-05fa00d4c63e32376 Step two is to...

Getting Started with AWS CloudFormation

Greetings! AWS CloudFormation is an infrastructure as code (IaC) solution by AWS to model, provision, and manage AWS resources. Thus, giving us more time to focus on our applications that run in AWS. What we do is create a template in YAML or JSON format that describes all the resources we want to create, and CloudFormation takes to create it. We are free of manual work. Without too much theory, let's create an S3 bucket using CloudFormation. We don't have to worry about notations when we get started. Steps Define the CloudFormation template Upload it to AWS An IaC S3 Bucket First of all, let's create our template (cfn-s3.yml) Resources: HelloBucket: Type: AWS::S3::Bucket Step two is to upload this to AWS. Go to AWS CloudFormation Click on Stacks Click on Create stack -> with new resources Choose "Template is ready" Choose "Upload a file...

Let's create a REST API with AWS Lambda, API Gateway, and DynamoDB

 Greetings! I recently started learning AWS serverless. Hence thought to write a little about creating an API in a serverless way. In this post, I am using the manual process, even though it is not the best practice. On a later topic, we will use IaC to build the same. What is serverless? Serverless computing means that the cloud provider manages all the necessary infrastructure as the developers can concentrate on the business logic. This does not mean that there are no servers but we developers do not manage them. What is Lambda AWS Lambda is a serverless, event-driven, compute service that lets you run code without provisioning or managing servers. What API Gateway AWS API Gateway is a fully manages service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale. It acts as the "front door" for applications to access backend services. What is DynamoDB AWS DynamoDB is a fully manages, serverless, key-value NoSQL ...

ES6 and beyond

Greetings! JavaScript got a boost with ES6 and new ECMAScript specifications. However, as we are used to old ways, it might feel weird to use these new features and we will miss them as well. This is a list of useful features without lengthy explanations. What to expect let, const over var Arrow functions for .. of a new loop Promise promises no callback hell async, await further simplifies the promise Template literals Default values Shorthand assignment Rest parameter Spread operator Destructuring class map, set Modules Nullability let, const over var We are used to 'var' so that we forget the problems that come with it. ES6 introduces let and const to overcome those issues. It provides block scoping that was missing in 'var'. var name = 'Jon'; // now let firstName = 'Jon'; const another = 'You can not change this'; Arrow functions We are using the function syntax from the beginning but arrow fu...