Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

JINIers

cloudformaiton 이용 네트워크 구성하기(autoscaling 생성) 본문

AWS/이것저것

cloudformaiton 이용 네트워크 구성하기(autoscaling 생성)

JINIers 2024. 3. 29. 09:58

네트워크 구성순서

autoscaling을 하려면 그전에 launch template을 만들어야하는데 그걸 만들지않으면 autoscaling서비스가 만들어지지않는다.

지짜.. 이걸.. 일주일 넘게... 끙끙거리다가 완성함 큐ㅠㅠㅠ

 

 

그래도.. 성공했서...

그럼 됐찌.. 웅..


autoscaling

AWSTemplateFormatVersion: "2010-09-09"
Description: "before autoscaling launch template setting and autoscaling system"

Parameters:
  NetworkStackName:
    Description: "Name of an active CloudFormation stack that contains the networking resources, such as the VPC and subnet that will be used in this stack."
    Type: String
    MinLength: 1
    MaxLength: 128
    AllowedPattern: '^[a-zA-Z][-a-zA-Z0-9]*$'
    Default: vpc
  LBStackName:
    Description: "Loadbalance and targetgroup."
    Type: String
    MinLength: 1
    MaxLength: 128
    AllowedPattern: '^[a-zA-Z][-a-zA-Z0-9]*$'
    Default: lb
  KeyName:
    Description: EC2 KeyPair connect instance
    Type: AWS::EC2::KeyPair::KeyName
    Default: 'test'
  AMI:
    Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
    Description: 'The ID of the AMI.'
    Default: /aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-x86_64

# Autoscaling Type
  Ec2AutoscaleMinSize:
    Description: AutoScalingGroup MinSize
    Type: String
    Default: '1'
  Ec2AutoscaleMaxSize:
    Description: AutoScalingGroup MaxSize
    Type: String
    Default: '5'
  Ec2AutoscaleDesiredCapacity:
    Description: AutoScalingGroup DesiredCapacity
    Type: String
    Default: '1'

Resources:
# Launch Template
  testLaunTem:
    Type: AWS::EC2::LaunchTemplate
    Properties:
      LaunchTemplateName: !Sub '${AWS::StackName}-launch-template'
      LaunchTemplateData:
        ImageId: !Ref AMI
        InstanceType: t2.micro
        KeyName: !Ref KeyName
        SecurityGroupIds: 
          - !ImportValue
            Fn::Sub: "${NetworkStackName}-vpcASG"

# Autoscaling Group
  testAuG:
    Type: AWS::AutoScaling::AutoScalingGroup
    DependsOn: 
        - "testLaunTem"
    Properties:
      VPCZoneIdentifier:
          - !ImportValue
            Fn::Sub: ${NetworkStackName}-PublicSubnetA
          - !ImportValue
            Fn::Sub: ${NetworkStackName}-PublicSubnetB
      Cooldown: 300
      HealthCheckGracePeriod: 300
      HealthCheckType: EC2
      LaunchTemplate: 
        LaunchTemplateId: !Ref testLaunTem
        Version: !GetAtt 'testLaunTem.LatestVersionNumber'
      TargetGroupARNs: 
          - Fn::ImportValue: !Sub ${LBStackName}-testTargetGroup
      MinSize: !Ref 'Ec2AutoscaleMinSize'
      MaxSize: !Ref 'Ec2AutoscaleMaxSize'
      DesiredCapacity: !Ref 'Ec2AutoscaleDesiredCapacity'

 


aws docs 보고 열심히 작성했는데 돌리는데 자꾸 양식 에러가 나는거임

그래서 ai의 도움을 받았다

에러 코드 수정해달라고해서 돌렸는데 안되가지고

 

개찡찡거림ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ

 

계속 수정하고 돌리고 수정하고 돌리고 해서 결국 되긴 됐다

그게 저 위에거

기분 좋아서 챗gpt 칭찬해줌

칭찬해줘서 신난거같음ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ

 

하 그래도 한 3주정도 낑낑거려서 오토스케일링까지 cloudformaiton으로 작성해봤다.

이제 좀 cloudformation 파일 작성하는거에 감을 잡은 듯

신난다. 이제 또 뭘 해볼까

3. create-launchtemplate-autoscaling.yaml
0.00MB

Comments