2017-03-16 20:42:33 +01:00
|
|
|
---
|
2017-04-03 19:53:38 +02:00
|
|
|
layout: "enterprise"
|
2017-04-07 06:00:12 +02:00
|
|
|
page_title: "Managing Versions - Artifacts - Terraform Enterprise"
|
2017-03-23 20:28:10 +01:00
|
|
|
sidebar_current: "docs-enterprise-artifacts-versions"
|
2017-03-17 22:34:04 +01:00
|
|
|
description: |-
|
|
|
|
Artifacts are versioned and assigned a version number, here is how to manage the versions.
|
2017-03-16 20:42:33 +01:00
|
|
|
---
|
|
|
|
|
|
|
|
# Managing Artifact Versions
|
|
|
|
|
2017-04-07 06:00:12 +02:00
|
|
|
Artifacts stored in Terraform Enterprise are versioned and assigned a version
|
|
|
|
number. Versions are useful to roll back, audit and deploy images specific
|
|
|
|
versions of images to certain environments in a targeted way.
|
2017-03-16 20:42:33 +01:00
|
|
|
|
2017-04-07 17:36:49 +02:00
|
|
|
This assumes you are familiar with the [artifact provider](https://terraform.io/docs/providers/terraform-enterprise/index.html)
|
2017-03-16 20:42:33 +01:00
|
|
|
in Terraform.
|
|
|
|
|
|
|
|
### Finding the Version of an Artifact
|
|
|
|
|
|
|
|
Artifact versions can be found with the [`terraform show` command](https://terraform.io/docs/commands/show.html),
|
|
|
|
or by looking at the Packer logs generated during builds. After a
|
|
|
|
successful artifact upload, version numbers are displayed. "latest" can
|
|
|
|
be used to use the latest version of the artifact.
|
|
|
|
|
|
|
|
The following output is from `terraform show`.
|
|
|
|
|
2017-04-07 06:00:12 +02:00
|
|
|
```text
|
|
|
|
atlas_artifact.web-worker:
|
|
|
|
id = us-east-1:ami-3a0a1d52
|
|
|
|
build = latest
|
|
|
|
metadata_full.# = 1
|
|
|
|
metadata_full.region-us-east-1 = ami-3a0a1d52
|
|
|
|
name = my-username/web-worker
|
|
|
|
slug = my-username/web-worker/amazon.image/7
|
|
|
|
type = amazon.image
|
|
|
|
```
|
2017-03-16 20:42:33 +01:00
|
|
|
|
|
|
|
In this case, the version is 7 and can be found in the persisted slug
|
|
|
|
attribute.
|
|
|
|
|
|
|
|
### Pinning Artifacts to Specific Versions
|
|
|
|
|
|
|
|
You can pin artifacts to a specific version. This allows for a targeted
|
|
|
|
deploy.
|
|
|
|
|
2017-04-07 06:00:12 +02:00
|
|
|
```hcl
|
2017-05-25 23:24:24 +02:00
|
|
|
data "atlas_artifact" "web-worker" {
|
|
|
|
name = "my-username/web-worker"
|
|
|
|
type = "amazon.image"
|
2017-04-07 06:00:12 +02:00
|
|
|
version = 7
|
|
|
|
}
|
|
|
|
```
|
2017-03-16 20:42:33 +01:00
|
|
|
|
|
|
|
This will use version 7 of the `web-worker` artifact.
|
|
|
|
|
|
|
|
### Pinning Artifacts to Specific Builds
|
|
|
|
|
2017-03-17 22:34:04 +01:00
|
|
|
Artifacts can also be pinned to an Terraform build number. This is only
|
|
|
|
possible if Terraform Enterprise was used to build the artifact with Packer.
|
2017-03-16 20:42:33 +01:00
|
|
|
|
2017-04-07 06:00:12 +02:00
|
|
|
```hcl
|
2017-05-25 23:24:24 +02:00
|
|
|
data "atlas_artifact" "web-worker" {
|
2017-04-07 06:00:12 +02:00
|
|
|
name = "my-username/web-worker"
|
|
|
|
type = "amazon.image"
|
|
|
|
build = 5
|
|
|
|
}
|
|
|
|
```
|
2017-03-16 20:42:33 +01:00
|
|
|
|
2017-04-07 06:00:12 +02:00
|
|
|
It's recommended to use versions, instead of builds, as it will be easier to
|
|
|
|
track when building outside of the Terraform Enterprise environment.
|