VaultLock class

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 this provider 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.

> NOTE: We suggest using jsonencode() or aws.iam.getPolicyDocument when assigning a value to policy. They seamlessly translate Terraform language into JSON, enabling you to maintain consistency within your configuration without the need for context switches. Also, you can sidestep potential complications arising from formatting discrepancies, whitespace inconsistencies, and other nuances inherent to JSON.

> 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 this provider will return an error. Set the ignoreDeletionError argument to true and apply this configuration before attempting to delete this resource via this provider or remove this resource from this provider's management.

Example Usage

Testing Glacier Vault Lock Policy

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const exampleVault = new aws.glacier.Vault("example", {name: "example"});
const example = aws.iam.getPolicyDocumentOutput({
    statements: [{
        conditions: [{
            test: "NumericLessThanEquals",
            variable: "glacier:ArchiveAgeinDays",
            values: ["365"],
        }],
        actions: ["glacier:DeleteArchive"],
        effect: "Deny",
        resources: [exampleVault.arn],
    }],
});
const exampleVaultLock = new aws.glacier.VaultLock("example", {
    completeLock: false,
    policy: example.json,
    vaultName: exampleVault.name,
});
import pulumi
import pulumi_aws as aws

example_vault = aws.glacier.Vault("example", name="example")
example = aws.iam.get_policy_document_output(statements=[{
    "conditions": [{
        "test": "NumericLessThanEquals",
        "variable": "glacier:ArchiveAgeinDays",
        "values": ["365"],
    }],
    "actions": ["glacier:DeleteArchive"],
    "effect": "Deny",
    "resources": [example_vault.arn],
}])
example_vault_lock = aws.glacier.VaultLock("example",
    complete_lock=False,
    policy=example.json,
    vault_name=example_vault.name)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var exampleVault = new Aws.Glacier.Vault("example", new()
    {
        Name = "example",
    });

    var example = Aws.Iam.GetPolicyDocument.Invoke(new()
    {
        Statements = new[]
        {
            new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
            {
                Conditions = new[]
                {
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
                    {
                        Test = "NumericLessThanEquals",
                        Variable = "glacier:ArchiveAgeinDays",
                        Values = new[]
                        {
                            "365",
                        },
                    },
                },
                Actions = new[]
                {
                    "glacier:DeleteArchive",
                },
                Effect = "Deny",
                Resources = new[]
                {
                    exampleVault.Arn,
                },
            },
        },
    });

    var exampleVaultLock = new Aws.Glacier.VaultLock("example", new()
    {
        CompleteLock = false,
        Policy = example.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
        VaultName = exampleVault.Name,
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/glacier"
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		exampleVault, err := glacier.NewVault(ctx, "example", &glacier.VaultArgs{
			Name: pulumi.String("example"),
		})
		if err != nil {
			return err
		}
		example := iam.GetPolicyDocumentOutput(ctx, iam.GetPolicyDocumentOutputArgs{
			Statements: iam.GetPolicyDocumentStatementArray{
				&iam.GetPolicyDocumentStatementArgs{
					Conditions: iam.GetPolicyDocumentStatementConditionArray{
						&iam.GetPolicyDocumentStatementConditionArgs{
							Test:     pulumi.String("NumericLessThanEquals"),
							Variable: pulumi.String("glacier:ArchiveAgeinDays"),
							Values: pulumi.StringArray{
								pulumi.String("365"),
							},
						},
					},
					Actions: pulumi.StringArray{
						pulumi.String("glacier:DeleteArchive"),
					},
					Effect: pulumi.String("Deny"),
					Resources: pulumi.StringArray{
						exampleVault.Arn,
					},
				},
			},
		}, nil)
		_, err = glacier.NewVaultLock(ctx, "example", &glacier.VaultLockArgs{
			CompleteLock: pulumi.Bool(false),
			Policy:       example.Json(),
			VaultName:    exampleVault.Name,
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

data "aws_iam_getpolicydocument" "example" {
  statements {
    conditions {
      test     = "NumericLessThanEquals"
      variable = "glacier:ArchiveAgeinDays"
      values   = ["365"]
    }
    actions   = ["glacier:DeleteArchive"]
    effect    = "Deny"
    resources = [aws_glacier_vault.example.arn]
  }
}

resource "aws_glacier_vault" "example" {
  name = "example"
}
resource "aws_glacier_vaultlock" "example" {
  complete_lock = false
  policy        = data.aws_iam_getpolicydocument.example.json
  vault_name    = aws_glacier_vault.example.name
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.glacier.Vault;
import com.pulumi.aws.glacier.VaultArgs;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementConditionArgs;
import com.pulumi.aws.glacier.VaultLock;
import com.pulumi.aws.glacier.VaultLockArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var exampleVault = new Vault("exampleVault", VaultArgs.builder()
            .name("example")
            .build());

        final var example = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
            .statements(GetPolicyDocumentStatementArgs.builder()
                .conditions(GetPolicyDocumentStatementConditionArgs.builder()
                    .test("NumericLessThanEquals")
                    .variable("glacier:ArchiveAgeinDays")
                    .values("365")
                    .build())
                .actions("glacier:DeleteArchive")
                .effect("Deny")
                .resources(exampleVault.arn())
                .build())
            .build());

        var exampleVaultLock = new VaultLock("exampleVaultLock", VaultLockArgs.builder()
            .completeLock(false)
            .policy(example.applyValue(_example -> _example.json()))
            .vaultName(exampleVault.name())
            .build());

    }
}
resources:
  exampleVault:
    type: aws:glacier:Vault
    name: example
    properties:
      name: example
  exampleVaultLock:
    type: aws:glacier:VaultLock
    name: example
    properties:
      completeLock: false
      policy: ${example.json}
      vaultName: ${exampleVault.name}
variables:
  example:
    fn::invoke:
      function: aws:iam:getPolicyDocument
      arguments:
        statements:
          - conditions:
              - test: NumericLessThanEquals
                variable: glacier:ArchiveAgeinDays
                values:
                  - '365'
            actions:
              - glacier:DeleteArchive
            effect: Deny
            resources:
              - ${exampleVault.arn}

Permanently Applying Glacier Vault Lock Policy

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.glacier.VaultLock("example", {
    completeLock: true,
    policy: exampleAwsIamPolicyDocument.json,
    vaultName: exampleAwsGlacierVault.name,
});
import pulumi
import pulumi_aws as aws

example = aws.glacier.VaultLock("example",
    complete_lock=True,
    policy=example_aws_iam_policy_document["json"],
    vault_name=example_aws_glacier_vault["name"])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var example = new Aws.Glacier.VaultLock("example", new()
    {
        CompleteLock = true,
        Policy = exampleAwsIamPolicyDocument.Json,
        VaultName = exampleAwsGlacierVault.Name,
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/glacier"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := glacier.NewVaultLock(ctx, "example", &glacier.VaultLockArgs{
			CompleteLock: pulumi.Bool(true),
			Policy:       pulumi.Any(exampleAwsIamPolicyDocument.Json),
			VaultName:    pulumi.Any(exampleAwsGlacierVault.Name),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_glacier_vaultlock" "example" {
  complete_lock = true
  policy        = exampleAwsIamPolicyDocument.json
  vault_name    = exampleAwsGlacierVault.name
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.glacier.VaultLock;
import com.pulumi.aws.glacier.VaultLockArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var example = new VaultLock("example", VaultLockArgs.builder()
            .completeLock(true)
            .policy(exampleAwsIamPolicyDocument.json())
            .vaultName(exampleAwsGlacierVault.name())
            .build());

    }
}
resources:
  example:
    type: aws:glacier:VaultLock
    properties:
      completeLock: true
      policy: ${exampleAwsIamPolicyDocument.json}
      vaultName: ${exampleAwsGlacierVault.name}

Import

Using pulumi import, import Glacier Vault Locks using the Glacier Vault name. For example:

$ pulumi import aws:glacier/vaultLock:VaultLock example example-vault

Constructors

VaultLock(String name, {VaultLockArgs? args, CustomResourceOptions? options})
Creates a new VaultLock. name The Pulumi resource name. args Arguments used to configure this VaultLock. The set of arguments for VaultLock. options Resource options controlling this resource's behavior.
VaultLock.reference(String urn)
Creates a typed reference to an existing VaultLock resource.

Properties

childResources → Set<Resource>
finalinherited
completeLock ↔ Output<bool>
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 this provider 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.
latefinal
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
hashCode → int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
ignoreDeletionError ↔ Output<bool?>
Allow this provider 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 this provider, for example, if the Glacier Vault Lock policy permits that action. This should only be used in conjunction with completeLock being set to true.
latefinal
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
policy ↔ Output<String>
JSON string containing the IAM policy to apply as the Glacier Vault Lock policy.
latefinal
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited
vaultName ↔ Output<String>
The name of the Glacier Vault.
latefinal

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {VaultLockState? state, CustomResourceOptions? options}) → VaultLock
Gets an existing VaultLock resource's state with the given name and id.