aws ec2 (AWS 가상 컴퓨팅) 에는 tag 라는놈을 달아줄 수 있습니다. 

이 Tag 는 ec2 이 외에도 여러가지 리소스에도 달아줄 수 있으며, 앞으로도 쭉 늘어날 예정입니다.


http://docs.aws.amazon.com/ko_kr/AWSEC2/latest/UserGuide/Using_Tags.html

위의 설명서에 tag 대한 설명이 자세하게 나와 있습니다.


Amazon EC2 리소스 태그 지정 지원

Resource태그 지원생성 시 태깅 지원(Amazon EC2 API, AWS CLI, AWS SDK)

AFI

아니요

아니요

AMI

아니요

번들 작업

아니요

아니요

고객 게이트웨이

아니요

전용 호스트

아니요

아니요

DHCP 옵션

아니요

EBS 스냅샷

아니요

EBS 볼륨

외부 전용 인터넷 게이트웨이

아니요

아니요

탄력적 IP 주소

아니요

아니요

인스턴스

인스턴스 스토어 볼륨

해당 사항 없음

해당 사항 없음

인터넷 게이트웨이

아니요

키 페어

아니요

아니요

NAT 게이트웨이

아니요

네트워크 ACL

아니요

네트워크 인터페이스

아니요

배치 그룹

아니요

아니요

예약 인스턴스

아니요

예약 인스턴스 목록

아니요

아니요
라우팅 테이블

아니요

스팟 인스턴스 요청

아니요

보안 group–EC2-Classic

아니요

보안 group–VPC

아니요

서브넷

아니요

가상 프라이빗 게이트웨이

아니요

VPC

아니요

VPC 엔드포인트

아니요

아니요

VPC 흐름 로그

아니요

아니요

VPC 피어링 연결

아니요

VPN 연결

아니요


ec2 에 tag 를 가지고 어떤것에 활용해야 할까요???

인프라를 코드로 관리하려면 이 tag 라는것이 많이 필요하게 됩니다. 


ec2 cli 를 확인하게되면 ec2 에서 tag 를 가지고 볼수 잇는 정보를 알 수 있습니다. 


총 4가지의 정보가 확인이 됩니다. 


http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-tags.html


Tags -> (list)

A list of tags.

(structure)

Describes a tag.

Key -> (string)

The tag key.

ResourceId -> (string)

The ID of the resource. For example, ami-1a2b3c4d .

ResourceType -> (string)

The resource type.

Value -> (string)

The tag value.


위의 4가지 정보를 가지고 filter 라는것을 통해 내가 원하는 리소스 (ec2) 를 분별이 가능합니다. 

ec2 에 어떠한 작업을 하는대 있어서 특정 대상을 분류 하는대에 tag 를 사용한다고 보시면 됩니다. 


Examples

To describe your tags

This example describes the tags for all your resources.

Command:

aws ec2 describe-tags

Output:

{
    "Tags": [
        {
            "ResourceType": "image",
            "ResourceId": "ami-78a54011",
            "Value": "Production",
            "Key": "Stack"
        },
        {
            "ResourceType": "image",
            "ResourceId": "ami-3ac33653",
            "Value": "Test",
            "Key": "Stack"
        },
        {
            "ResourceType": "instance",
            "ResourceId": "i-1234567890abcdef0",
            "Value": "Production",
            "Key": "Stack"
        },
        {
            "ResourceType": "instance",
            "ResourceId": "i-1234567890abcdef1",
            "Value": "Test",
            "Key": "Stack"
        },
        {
            "ResourceType": "instance",
            "ResourceId": "i-1234567890abcdef5",
            "Value": "Beta Server",
            "Key": "Name"
        },
        {
            "ResourceType": "volume",
            "ResourceId": "vol-049df61146c4d7901",
            "Value": "Project1",
            "Key": "Purpose"
        },
        {
            "ResourceType": "volume",
            "ResourceId": "vol-1234567890abcdef0",
            "Value": "Logs",
            "Key": "Purpose"
        }
    ]
}

To describe the tags for a single resource

This example describes the tags for the specified instance.

Command:

aws ec2 describe-tags --filters "Name=resource-id,Values=i-1234567890abcdef8"

Output:

{
    "Tags": [
        {
            "ResourceType": "instance",
            "ResourceId": "i-1234567890abcdef8",
            "Value": "Test",
            "Key": "Stack"
        },
        {
            "ResourceType": "instance",
            "ResourceId": "i-1234567890abcdef8",
            "Value": "Beta Server",
            "Key": "Name"
        }
    ]
}

To describe the tags for a type of resource

This example describes the tags for your volumes.

Command:

aws ec2 describe-tags --filters "Name=resource-type,Values=volume"

Output:

{
    "Tags": [
        {
            "ResourceType": "volume",
            "ResourceId": "vol-1234567890abcdef0",
            "Value": "Project1",
            "Key": "Purpose"
        },
        {
            "ResourceType": "volume",
            "ResourceId": "vol-049df61146c4d7901",
            "Value": "Logs",
            "Key": "Purpose"
        }
    ]
}

To describe the tags for your resources based on a key and a value

This example describes the tags for your resources that have the key Stack and a value Test.

Command:

aws ec2 describe-tags --filters "Name=key,Values=Stack" "Name=value,Values=Test"

Output:

{
    "Tags": [
        {
            "ResourceType": "image",
            "ResourceId": "ami-3ac33653",
            "Value": "Test",
            "Key": "Stack"
        },
        {
            "ResourceType": "instance",
            "ResourceId": "i-1234567890abcdef8",
            "Value": "Test",
            "Key": "Stack"
        }
    ]
}

This example describes the tags for all your instances that have a tag with the key Purpose and no value.

Command:

aws ec2 describe-tags --filters "Name=resource-type,Values=instance" "Name=key,Values=Purpose" "Name=value,Values="

Output:

{
    "Tags": [
        {
            "ResourceType": "instance",
            "ResourceId": "i-1234567890abcdef5",
            "Value": null,
            "Key": "Purpose"
        }
    ]
}

AWS 를 코드로 관리하시고자 하시는분들은  Tag의 활용성에 대해서 꼭 숙지하시길 바랍니다. 









'AWS > EC2' 카테고리의 다른 글

AMI EC2 에서 백업 스크립트  (0) 2017.10.25
EBS Volume 용량, iops 수정  (0) 2017.03.08
Amazon EC2 Systems Manager - 사전조건, 설치  (0) 2017.02.02

+ Recent posts