0% found this document useful (0 votes)
128 views3 pages

Aws 10

This document contains two templates that deploy a cafe application. The first template deploys the application code and dependencies on an EC2 instance in an existing VPC subnet and security group. It installs Apache, MariaDB, and PHP and downloads the application code from an S3 bucket. The second template configures an S3 bucket as a static website to host the application UI code.

Uploaded by

mahera Khatoon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
128 views3 pages

Aws 10

This document contains two templates that deploy a cafe application. The first template deploys the application code and dependencies on an EC2 instance in an existing VPC subnet and security group. It installs Apache, MariaDB, and PHP and downloads the application code from an S3 bucket. The second template configures an S3 bucket as a static website to host the application UI code.

Uploaded by

mahera Khatoon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

aws s3 cp templates/cafe-app.

yaml s3://c43621a584632l1206471t1w575771408041-
repobucket-4icrczp7qaql/
c43621a584632l1206471t1w575771408041-repobucket-4icrczp7qaql

================================================= cafe-network.yaml cafe-


app.yaml================================

AWSTemplateFormatVersion: 2010-09-09
Description: Cafe application

Parameters:
InstanceTypeParameter:
Type: String
Default: t2.small
AllowedValues:
- t2.micro
- t2.small
- t3.micro
- t3.small
Description: Enter t2.micro, t2.small, t3.micro, or t3.small. Default is
t2.small.

LatestAmiId:
Type: 'AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>'
Default: '/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2'

CafeNetworkParameter:
Type: String
Default: update-cafe-network

Mappings:

RegionMap:
us-east-1:
"keypair": "vockey"
us-west-2:
"keypair": "cafe-oregon"

Resources:
CafeSG:
Type: 'AWS::EC2::SecurityGroup'
Properties:
GroupDescription: Enable SSH, HTTP access
VpcId: !ImportValue
'Fn::Sub': '${CafeNetworkParameter}-VpcID'
Tags:
- Key: Name
Value: CafeSG
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '80'
ToPort: '80'
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: '22'
ToPort: '22'
CidrIp: 0.0.0.0/0
CafeInstance:
Type: 'AWS::EC2::Instance'
Properties:
ImageId: !Ref LatestAmiId
InstanceType: !Ref InstanceTypeParameter
KeyName: !FindInMap [RegionMap, !Ref "AWS::Region", keypair]
#IamInstanceProfile: CafeRole
NetworkInterfaces:
- DeviceIndex: '0'
AssociatePublicIpAddress: true
SubnetId: !ImportValue
'Fn::Sub': '${CafeNetworkParameter}-SubnetID'
GroupSet:
- !Ref CafeSG
Tags:
- Key: Name
Value: Cafe Web Server

UserData:
Fn::Base64:
!Sub |
#!/bin/bash

yum -y update

yum install -y httpd mariadb-server wget

amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2

systemctl enable httpd

systemctl start httpd

systemctl enable mariadb

systemctl start mariadb

wget https://aws-tc-largeobjects.s3-us-west-2.amazonaws.com/ILT-TF-200-
ACACAD-20-EN/mod10-challenge/cafe-app.sh

chmod +x cafe-app.sh

./cafe-app.sh

Outputs:
WebServerPublicIP:
Value: !GetAtt 'CafeInstance.PublicIp'

======================================================================S3.yaml
AWSTemplateFormatVersion: "2010-09-09"
Description: cafe S3 template
Resources:
S3Bucket:
Type: AWS::S3::Bucket
DeletionPolicy: Retain
Properties:
WebsiteConfiguration:
IndexDocument: index.html

Outputs:
WebsiteURL:
Value: !GetAtt
- S3Bucket
- WebsiteURL
Description: URL for website hosted on S3

You might also like