AWS CloudFormation
cloud AWS

5 minutes


go back go back go back home home

AWS CloudFormation Introduction

CloudFormation is a declairative way of outlining your AWS infrastructure for any resources (most of them are supported!).

For example with a cloud example you can say:

Then cloudformation creates those things for you in the right order with the exact configuration that you specify!


Infrastructure as a code

Cost

Productivity

Dont re-invent the wheel

Productivity

CloudFormation Stack Designer

For example :

# o-just-ec2.yaml file
Parameters:
	SecurityGroupDescription:
		Description: "Security group lorem ipsum other text"
		Type: String

Resources:
	MyInstance:
		Type: AWS::EC2::Instance
		properties:
			AvailablityZones: us-east-1a
			ImageId: ami-a4c7edb2
			InstanceType: t2.micro
			SecurityGroups:
				- !Ref SSHSecurityGroup
				- !Ref ServerSecurityGroup
	# An Elastic IP For our instance
	MyEIP:
		Type: AWS::EC2::EIP
		Properties:
			InstanceId: !Ref MyInstance
	# Our EC2 Security Group
	SSHSecurityGroup:
		Type: AWS::EC2::SecurityGroup
		Properties:
			GroupDescription: "Enable SSH access via ort 22"
			SecurityGroupIngress:
				- CidrIP: 0.0.0.0/0
				- FromPort: 22
				- IpProtocol: TCP
				- ToPort: 22
	# Our Second EC2 Security Group
	ServerSecurityGroup:
		Type: AWS::EC2::SecurityGroup
		Properties:
			GroupDescription: "Security Grp"
			SecurityGroupIngress:
				- IpProtocol: TCP
				FromPort: 80
				ToPort: 80
				CidrIP: 0.0.0.0/0
				- IpProtocol: TCP
				FromPort: 22
				ToPort: 22
				#your localmachine IP For SSH
				CidrIP: 192.168.1.1/32
# This section will print out allocated Elastic IP!
Outputs:
	ElasticIP:
		Description: ElasticIP Value
		Value: !Ref MyEIP

Visual Representation

"cloudformation"