create an aws cloudformation template with an ec2 instance in us-east-1 region with…
- User
create an aws cloudformation template with an ec2 instance in us-east-1 region with key-pair having a security group with inbound ssh rules
Assistant
To create an AWS CloudFormation template with an EC2 instance in the us-east-1 region, a key-pair, a security group with inbound SSH rules, follow these steps:
- Define the AWS::EC2::SecurityGroup resource with the required properties, such as GroupDescription, GroupName, and SecurityGroupIngress.
- Create an AWS::EC2::Instance resource with the required properties, such as ImageId, KeyName, and SecurityGroups.
Here's an example template:
AWSTemplateFormatVersion: '2010-09-09' Resources: MySecurityGroup: Type: 'AWS::EC2::SecurityGroup' Properties: GroupDescription: Enable SSH access via port 22 SecurityGroupIngress: - IpProtocol: tcp FromPort: 22 ToPort: 22 CidrIp: 0.0.0.0/0 MyEC2Instance: Type: 'AWS::EC2::Instance' Properties: ImageId: ami-7a11e213 KeyName: MyKeyPair SecurityGroups: - !Ref MySecurityGroup
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.