hcp-packer-version
hcp-packer-version
hcp-packer-version 데이터 소스는 HCP Packer 레지스트리에서 HCP Packer 버전에 대한 정보를 가져와요. 이 버전 정보를 활용해 HCP에 소스의 외부 식별자(external identifier)를 질의해서, 다양한 Packer builder에서 사용할 수 있어요.
출처: Packer 공식 문서
본문
HCP Packer를 시작하려면 HCP Packer 문서를 참고하거나 HCP Packer 시작 튜토리얼을 따라 해 보세요.
비활성화되거나 삭제된 레지스트리의 메타데이터를 참조하려 하면 Packer는 오류를 출력해요. 관리자가 레지스트리를 수동으로 비활성화하거나 삭제할 수 있고, HCP Packer는 결제 문제가 있는 레지스트리를 자동으로 비활성화해요. 궁금한 점은 HashiCorp Support에 문의해 주세요.
폐기된 버전 (Revoked Versions)
HCP Packer 버전이 폐기(revoked)되면 hcp-packer-version 데이터 소스는 실패하고 Packer는 빌드를 진행하지 않아요. 폐기된 아티팩트에서 새 아티팩트를 빌드하는 건 규정 위반이에요. 폐기 예정인 버전은 폐기 날짜까지는 계속 유효한 것으로 간주돼요.
기본 예시 (Basic Example)
아래는 완전히 동작하는 예시예요. HCP Packer 버전에 대한 정보를 저장하고, 그 정보를 변수로 접근할 수 있게 해줘요.
data "hcp-packer-version" "hardened-source" {
bucket_name = "hardened-ubuntu-16-04"
channel_name = "dev"
}
전체 예시 (Full Example)
이 데이터 소스는 hcp-packer-artifact 데이터 소스와 함께 쓰면 아티팩트 식별자를 가져올 수 있어요. 버전 데이터 소스에 버전 지문(fingerprint)과 채널 이름을 제공하고, 아티팩트 데이터 소스 안에서 버전 소스를 사용한 뒤, source 블록 안에서 아티팩트 데이터 소스를 사용하면 됩니다.
# Retrieves information about the HCP Packer Version; a "version" can be
# thought of as all the metadata created by a single call of `packer build`.
data "hcp-packer-version" "hardened-source" {
bucket_name = "hardened-ubuntu-16-04"
channel_name = "dev"
}
# Retrieves information about the HCP Packer Artifact; an artifact can be thought
# of as all the metadata (including the artifact names) created by a single
# "source" builder; this can include multiple artifacts so we provide a
# region to disambiguate.
data "hcp-packer-artifact" "example" {
bucket_name = "hardened-ubuntu-16-04"
version_fingerprint = data.hcp-packer-version.hardened-source.fingerprint
platform = "aws"
region = "us-east-1"
}
# This source uses the output from a previous Packer build. By using the
# HCP Packer Registry in this way, you can easily create build pipelines where
# a single base artifact can be customized in multiple secondary layers.
source "amazon-ebs" "packer-secondary" {
source_ami = data.hcp-packer-artifact.example.external_identifier
...
}
설정 레퍼런스 (Configuration Reference)
설정 옵션은 필수(required)와 선택(optional) 두 범주로 정리돼요. 각 범주 안에서 사용 가능한 옵션은 알파벳순으로 정렬되어 설명돼요.
필수 (Required):
bucket_name(string) - HCP Packer 레지스트리의 버킷 이름.channel_name(string) - 버전을 가져올 때 사용할 주어진 버킷의 채널 이름.
현재 이 데이터 소스에는 선택 필드가 없어요. 다만 향후 필터링 필드를 추가할 계획이에요.
출력 필드 (Output Fields):
author_id(string) - 이 버전을 만든 작성자의 이름.bucket_name(string) - 이 버전이 연관된 버킷의 이름.status(string) - 버전의 현재 상태.created_at(string) - 버전이 생성된 날짜.fingerprint(string) - 버전의 지문. 이 버전을 만든 Packer 빌드가 설정한 고유 식별자예요.id(string) - 버전 ID. UUID와 비슷한 고유 식별자인 ULID예요. 버전이 처음 생성될 때 HCP Packer 레지스트리가 만들어 주며, 이 버전에 고유해요.name(string) - 버전 이름은 버전이 "완료(complete)"되면 HCP Packer 레지스트리가 만들어 줘요. 불완전하거나 실패한 버전은 현재 이름이 기본값 "v0"이에요.updated_at(string) - 이 버전이 마지막으로 업데이트된 날짜.channel_id(string) - 이 버전을 질의하는 데 사용한 채널의 ID.