CLI로 ModifyLoadBalancerAttributes 사용 - AWS SDK 코드 예제

AWS SDK 예제 GitHub 리포지토리에 더 많은 AWS문서 SDK 예제가 있습니다.

CLI로 ModifyLoadBalancerAttributes 사용

다음 코드 예시는 ModifyLoadBalancerAttributes의 사용 방법을 보여 줍니다.

CLI
AWS CLI

삭제 보호를 활성화하려면

이 예시에서는 지정된 로드 밸런서에 대한 삭제 보호를 활성화합니다.

명령:

aws elbv2 modify-load-balancer-attributes --load-balancer-arn arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188 --attributes Key=deletion_protection.enabled,Value=true

출력:

{ "Attributes": [ { "Value": "true", "Key": "deletion_protection.enabled" }, { "Value": "false", "Key": "access_logs.s3.enabled" }, { "Value": "60", "Key": "idle_timeout.timeout_seconds" }, { "Value": "", "Key": "access_logs.s3.prefix" }, { "Value": "", "Key": "access_logs.s3.bucket" } ] }

유휴 제한 시간을 변경하려면

이 예시에서는 지정된 로드 밸런서에 대한 유휴 제한 시간 값을 변경합니다.

명령:

aws elbv2 modify-load-balancer-attributes --load-balancer-arn arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188 --attributes Key=idle_timeout.timeout_seconds,Value=30

출력:

{ "Attributes": [ { "Value": "30", "Key": "idle_timeout.timeout_seconds" }, { "Value": "false", "Key": "access_logs.s3.enabled" }, { "Value": "", "Key": "access_logs.s3.prefix" }, { "Value": "true", "Key": "deletion_protection.enabled" }, { "Value": "", "Key": "access_logs.s3.bucket" } ] }

액세스 로그를 활성화하려면

이 예시에서는 지정된 로드 밸런서에 대한 액세스 로그를 활성화합니다. S3 버킷은 로드 밸런서와 동일한 리전에 존재해야 하며, Elastic Load Balancing 서비스에 대한 액세스 권한을 부여하는 정책이 연결되어 있어야 합니다.

명령:

aws elbv2 modify-load-balancer-attributes --load-balancer-arn arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188 --attributes Key=access_logs.s3.enabled,Value=true Key=access_logs.s3.bucket,Value=my-loadbalancer-logs Key=access_logs.s3.prefix,Value=myapp

출력:

{ "Attributes": [ { "Value": "true", "Key": "access_logs.s3.enabled" }, { "Value": "my-load-balancer-logs", "Key": "access_logs.s3.bucket" }, { "Value": "myapp", "Key": "access_logs.s3.prefix" }, { "Value": "60", "Key": "idle_timeout.timeout_seconds" }, { "Value": "false", "Key": "deletion_protection.enabled" } ] }
PowerShell
Tools for PowerShell V4

예제 1: 이 예제에서는 지정된 로드 밸런서의 속성을 수정합니다.

Edit-ELB2LoadBalancerAttribute -LoadBalancerArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/test-alb/3651b4394dd9a24f' -Attribute @{Key = 'deletion_protection.enabled'; Value = 'true'}

출력:

Key Value --- ----- deletion_protection.enabled true access_logs.s3.enabled false access_logs.s3.bucket access_logs.s3.prefix idle_timeout.timeout_seconds 60 routing.http2.enabled true routing.http.drop_invalid_header_fields.enabled false
Tools for PowerShell V5

예제 1: 이 예제에서는 지정된 로드 밸런서의 속성을 수정합니다.

Edit-ELB2LoadBalancerAttribute -LoadBalancerArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/test-alb/3651b4394dd9a24f' -Attribute @{Key = 'deletion_protection.enabled'; Value = 'true'}

출력:

Key Value --- ----- deletion_protection.enabled true access_logs.s3.enabled false access_logs.s3.bucket access_logs.s3.prefix idle_timeout.timeout_seconds 60 routing.http2.enabled true routing.http.drop_invalid_header_fields.enabled false