三歩あるけば物も忘れる

お腹のお肉がメタボックル

ユーザ用ツール

サイト用ツール


Aws:CloudFormation:Sample001

サンプルEC2インスタンス

Amazonlinux2
AWSTemplateFormatVersion: "2010-09-09"
Description: CreateEC2Instance

Parameters:
  PrmCostTagValue:
    Type: String
    Default: Cost

  PrmInstanceProfile:
    Type: String
    Default: XXXXXX-Role
  
  PrmEc2ImageId:
    Type: AWS::EC2::Image::Id
    Default: ami-0329eac6c5240c99d

  PrmSecurityGroupId:
    Type: AWS::EC2::SecurityGroup::Id

  PrmSubnetId:
    Type: AWS::EC2::Subnet::Id

  PrmInstanceType:
    Type: String
    Default: t2.micro
    AllowedValues:
      - t2.micro
      - t2.small
      - t3.micro
      - t3.small

  PrmKeyPair:
    Type: AWS::EC2::KeyPair::KeyName
  
  PrmInstanceName:
    Type: String
    Default: InstanceName

  PrmPublicIpAddress:
    Type: String
    AllowedValues:
      - true
      - false
    
Resources:
### EC2 Instances ###
  ResEC2Instances01: 
    Type: AWS::EC2::Instance
    Properties: 
      ImageId: !Ref PrmEc2ImageId
      KeyName: !Ref PrmKeyPair
      InstanceType: !Ref PrmInstanceType
      NetworkInterfaces: 
        - AssociatePublicIpAddress: !Ref PrmPublicIpAddress
          DeviceIndex: "0"
          SubnetId: !Ref PrmSubnetId
          GroupSet:
            - !Ref PrmSecurityGroupId
      IamInstanceProfile: !Ref PrmInstanceProfile
      BlockDeviceMappings:
        - DeviceName: "/dev/xvda"
          Ebs:
            VolumeType: gp2
            VolumeSize: 8
            DeleteOnTermination: true
            Encrypted: false
      Tags:
          - Key: Name
            Value: !Ref PrmInstanceName
          - Key: Cost
            Value: !Ref PrmCostTagValue

Aws/CloudFormation/Sample001.txt · 最終更新: 2023/03/16 by admin