Create a ec2 instance and security group tied together with ''!Ref'' and an s3 bucket.

Resources:
  Ec2Instance:
    Type: AWS::EC2::Instance
    Properties:
      InstanceType: t2.micro
      ImageId: ami-07d9160fa81ccffb5 # Amazon Linux AMI in Ireland
      Tags:
        - Key: Name
          Value: AJS -  simple EC2 example
        - Key: email
          Value: myname@company.co.uk
        - Key: BuiltBy
          Value: CloudFormation
        - Key: JoinTest
          Value: !Join [ ":", [ Join, Example, in, YAML ] ]
      SecurityGroups:
        - !Ref SecurityGroupSSH

  SecurityGroupSSH:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupDescription: Allow SSH
      SecurityGroupIngress:
        - IpProtocol: tcp
          FromPort: '22'
          ToPort: '22'
          CidrIp: 0.0.0.0/0
      Tags:
        - Key: Name
          Value: AJS - Allow SSH

  S3BucketExample:
    Type: AWS::S3::Bucket
    Properties:
      AccessControl: PublicRead
      BucketName: ajs-bucket
      WebsiteConfiguration:
        IndexDocument: index.html
      Tags:
        - Key: Name
          Value: AJSTestBucket
        - Key: builtby
          Value: CloudFormation
 
aws/aws-cloudformation_refs.txt · Last modified: 15/02/2024 10:13 by andrew