Skip to content

Resource: awsGlacierVaultLock

Manages a Glacier Vault Lock. You can refer to the Glacier Developer Guide for a full explanation of the Glacier Vault Lock functionality.

\~> NOTE: This resource allows you to test Glacier Vault Lock policies by setting the completeLock argument to false. When testing policies in this manner, the Glacier Vault Lock automatically expires after 24 hours and Terraform will show this resource as needing recreation after that time. To permanently apply the policy, set the completeLock argument to true. When changing completeLock to true, it is expected the resource will show as recreating.

!> WARNING: Once a Glacier Vault Lock is completed, it is immutable. The deletion of the Glacier Vault Lock is not be possible and attempting to remove it from Terraform will return an error. Set the ignoreDeletionError argument to true and apply this configuration before attempting to delete this resource via Terraform or use terraformStateRm to remove this resource from Terraform management.

Example Usage

Testing Glacier Vault Lock Policy

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsGlacierVaultExample = new aws.glacierVault.GlacierVault(
  this,
  "example",
  {
    name: "example",
  }
);
const dataAwsIamPolicyDocumentExample =
  new aws.dataAwsIamPolicyDocument.DataAwsIamPolicyDocument(this, "example_1", {
    statement: [
      {
        actions: ["glacier:DeleteArchive"],
        condition: [
          {
            test: "NumericLessThanEquals",
            values: ["365"],
            variable: "glacier:ArchiveAgeinDays",
          },
        ],
        effect: "Deny",
        resources: [awsGlacierVaultExample.arn],
      },
    ],
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
dataAwsIamPolicyDocumentExample.overrideLogicalId("example");
const awsGlacierVaultLockExample = new aws.glacierVaultLock.GlacierVaultLock(
  this,
  "example_2",
  {
    completeLock: false,
    policy: dataAwsIamPolicyDocumentExample.json,
    vaultName: awsGlacierVaultExample.name,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsGlacierVaultLockExample.overrideLogicalId("example");

Permanently Applying Glacier Vault Lock Policy

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.glacierVaultLock.GlacierVaultLock(this, "example", {
  completeLock: true,
  policy: "${data.aws_iam_policy_document.example.json}",
  vaultName: "${aws_glacier_vault.example.name}",
});

Argument Reference

The following arguments are supported:

  • completeLock - (Required) Boolean whether to permanently apply this Glacier Lock Policy. Once completed, this cannot be undone. If set to false, the Glacier Lock Policy remains in a testing mode for 24 hours. After that time, the Glacier Lock Policy is automatically removed by Glacier and the Terraform resource will show as needing recreation. Changing this from false to true will show as resource recreation, which is expected. Changing this from true to false is not possible unless the Glacier Vault is recreated at the same time.
  • policy - (Required) JSON string containing the IAM policy to apply as the Glacier Vault Lock policy.
  • vaultName - (Required) The name of the Glacier Vault.
  • ignoreDeletionError - (Optional) Allow Terraform to ignore the error returned when attempting to delete the Glacier Lock Policy. This can be used to delete or recreate the Glacier Vault via Terraform, for example, if the Glacier Vault Lock policy permits that action. This should only be used in conjunction with completeLock being set to true.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - Glacier Vault name.

Import

Glacier Vault Locks can be imported using the Glacier Vault name, e.g.,

$ terraform import aws_glacier_vault_lock.example example-vault