In this demo, we will:
AWSServiceCatalogAdminFullAccess
PowerUserAccess
ServiceCatalogLaunchRole
Development Environment Portfolio
Standardized development environments for engineering teams
IT Operations Team
Create a file named development-ec2-template.yaml with the following content:
development-ec2-template.yaml
AWSTemplateFormatVersion: '2010-09-09'
Description: 'Development EC2 Instance - Service Catalog Product'
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: "Instance Configuration"
Parameters:
- InstanceType
- KeyPairName
- Label:
default: "Environment Settings"
Parameters:
- EnvironmentName
ParameterLabels:
InstanceType:
default: "EC2 Instance Type"
KeyPairName:
default: "SSH Key Pair"
EnvironmentName:
default: "Environment Name"
Parameters:
InstanceType:
Type: String
Default: t3.micro
AllowedValues:
- t2.micro
- t2.small
- t3.micro
- t3.small
Description: EC2 instance type for development environment
EnvironmentName:
Type: String
Default: Development
Description: Environment name tag for the instance
MinLength: 1
MaxLength: 50
KeyPairName:
Type: AWS::EC2::KeyPair::KeyName
Description: Name of an existing EC2 KeyPair to enable SSH access
ConstraintDescription: Must be the name of an existing EC2 KeyPair
Mappings:
RegionMap:
us-east-1:
AMI: ami-00ca32bbc84273381 # Amazon Linux 2023
us-west-1:
AMI: ami-0e0ece251c1638797 # Amazon Linux 2023
us-west-2:
AMI: ami-002829755fa238bfa # Amazon Linux 2023
us-east-2:
AMI: ami-024e6efaf93d85776 # Amazon Linux 2023
eu-west-1:
AMI: ami-0b9fd8b55a6e3c9d5 # Amazon Linux 2023
eu-central-1:
AMI: ami-0669b163befffbdfc # Amazon Linux 2023
ap-southeast-1:
AMI: ami-0464f90f5928bccb8 # Amazon Linux 2023
ap-northeast-1:
AMI: ami-089a156ea4f52a0a3 # Amazon Linux 2023
Resources:
DevelopmentSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Security group for development EC2 instance
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 443
ToPort: 443
CidrIp: 0.0.0.0/0
Tags:
- Key: Name
Value: !Sub ${EnvironmentName}-SecurityGroup
- Key: Environment
Value: !Ref EnvironmentName
DevelopmentInstance:
Type: AWS::EC2::Instance
Properties:
InstanceType: !Ref InstanceType
ImageId: !FindInMap [ RegionMap, !Ref 'AWS::Region', AMI ]
KeyName: !Ref KeyPairName
SecurityGroups:
- !Ref DevelopmentSecurityGroup
Tags:
- Key: Name
Value: !Sub ${EnvironmentName}-Instance
- Key: Environment
Value: !Ref EnvironmentName
- Key: ManagedBy
Value: ServiceCatalog
UserData:
Fn::Base64: !Sub |
#!/bin/bash
dnf update -y
dnf install -y httpd
systemctl start httpd
systemctl enable httpd
echo "<h1>Development Environment - ${EnvironmentName}</h1>" > /var/www/html/index.html
echo "<p>Instance Type: ${InstanceType}</p>" >> /var/www/html/index.html
echo "<p>Region: ${AWS::Region}</p>" >> /var/www/html/index.html
Outputs:
InstanceId:
Description: Instance ID of the development EC2 instance
Value: !Ref DevelopmentInstance
PublicIP:
Description: Public IP address of the instance
Value: !GetAtt DevelopmentInstance.PublicIp
WebURL:
Description: URL to access the web server
Value: !Sub 'http://${DevelopmentInstance.PublicIp}'
Development EC2 Instance
Pre-configured EC2 instance for development purposes with security group and web server
IT Operations
it-support@company.com
https://wiki.company.com/service-catalog
ServiceCatalog TestUser
AWSServiceCatalogEndUserFullAccess
AmazonS3ReadOnlyAccess
AWSCloudFormationReadOnlyAccess
dev-keypair
MyDevEnvironment-001
dev-keypair
delete
Delete