VaultPolicy class
Provides an AWS Backup vault policy resource.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const current = aws.getCallerIdentity({});
const exampleVault = new aws.backup.Vault("example", {name: "example"});
const example = aws.iam.getPolicyDocumentOutput({
statements: [{
principals: [{
type: "AWS",
identifiers: [current.then(current => current.accountId)],
}],
effect: "Allow",
actions: [
"backup:DescribeBackupVault",
"backup:DeleteBackupVault",
"backup:PutBackupVaultAccessPolicy",
"backup:DeleteBackupVaultAccessPolicy",
"backup:GetBackupVaultAccessPolicy",
"backup:StartBackupJob",
"backup:GetBackupVaultNotifications",
"backup:PutBackupVaultNotifications",
],
resources: [exampleVault.arn],
}],
});
const exampleVaultPolicy = new aws.backup.VaultPolicy("example", {
backupVaultName: exampleVault.name,
policy: example.json,
});
import pulumi
import pulumi_aws as aws
current = aws.get_caller_identity()
example_vault = aws.backup.Vault("example", name="example")
example = aws.iam.get_policy_document_output(statements=[{
"principals": [{
"type": "AWS",
"identifiers": [current.account_id],
}],
"effect": "Allow",
"actions": [
"backup:DescribeBackupVault",
"backup:DeleteBackupVault",
"backup:PutBackupVaultAccessPolicy",
"backup:DeleteBackupVaultAccessPolicy",
"backup:GetBackupVaultAccessPolicy",
"backup:StartBackupJob",
"backup:GetBackupVaultNotifications",
"backup:PutBackupVaultNotifications",
],
"resources": [example_vault.arn],
}])
example_vault_policy = aws.backup.VaultPolicy("example",
backup_vault_name=example_vault.name,
policy=example.json)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var current = Aws.GetCallerIdentity.Invoke();
var exampleVault = new Aws.Backup.Vault("example", new()
{
Name = "example",
});
var example = Aws.Iam.GetPolicyDocument.Invoke(new()
{
Statements = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
{
Principals = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
{
Type = "AWS",
Identifiers = new[]
{
current.Apply(getCallerIdentityResult => getCallerIdentityResult.AccountId),
},
},
},
Effect = "Allow",
Actions = new[]
{
"backup:DescribeBackupVault",
"backup:DeleteBackupVault",
"backup:PutBackupVaultAccessPolicy",
"backup:DeleteBackupVaultAccessPolicy",
"backup:GetBackupVaultAccessPolicy",
"backup:StartBackupJob",
"backup:GetBackupVaultNotifications",
"backup:PutBackupVaultNotifications",
},
Resources = new[]
{
exampleVault.Arn,
},
},
},
});
var exampleVaultPolicy = new Aws.Backup.VaultPolicy("example", new()
{
BackupVaultName = exampleVault.Name,
Policy = example.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws"
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/backup"
"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 {
current, err := aws.GetCallerIdentity(ctx, &aws.GetCallerIdentityArgs{}, nil)
if err != nil {
return err
}
exampleVault, err := backup.NewVault(ctx, "example", &backup.VaultArgs{
Name: pulumi.String("example"),
})
if err != nil {
return err
}
example := iam.GetPolicyDocumentOutput(ctx, iam.GetPolicyDocumentOutputArgs{
Statements: iam.GetPolicyDocumentStatementArray{
&iam.GetPolicyDocumentStatementArgs{
Principals: iam.GetPolicyDocumentStatementPrincipalArray{
&iam.GetPolicyDocumentStatementPrincipalArgs{
Type: pulumi.String("AWS"),
Identifiers: pulumi.StringArray{
pulumi.String(current.AccountId),
},
},
},
Effect: pulumi.String("Allow"),
Actions: pulumi.StringArray{
pulumi.String("backup:DescribeBackupVault"),
pulumi.String("backup:DeleteBackupVault"),
pulumi.String("backup:PutBackupVaultAccessPolicy"),
pulumi.String("backup:DeleteBackupVaultAccessPolicy"),
pulumi.String("backup:GetBackupVaultAccessPolicy"),
pulumi.String("backup:StartBackupJob"),
pulumi.String("backup:GetBackupVaultNotifications"),
pulumi.String("backup:PutBackupVaultNotifications"),
},
Resources: pulumi.StringArray{
exampleVault.Arn,
},
},
},
}, nil)
_, err = backup.NewVaultPolicy(ctx, "example", &backup.VaultPolicyArgs{
BackupVaultName: exampleVault.Name,
Policy: example.Json(),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
data "aws_getcalleridentity" "current" {
}
data "aws_iam_getpolicydocument" "example" {
statements {
principals {
type = "AWS"
identifiers = [data.aws_getcalleridentity.current.account_id]
}
effect = "Allow"
actions = ["backup:DescribeBackupVault", "backup:DeleteBackupVault", "backup:PutBackupVaultAccessPolicy", "backup:DeleteBackupVaultAccessPolicy", "backup:GetBackupVaultAccessPolicy", "backup:StartBackupJob", "backup:GetBackupVaultNotifications", "backup:PutBackupVaultNotifications"]
resources = [aws_backup_vault.example.arn]
}
}
resource "aws_backup_vault" "example" {
name = "example"
}
resource "aws_backup_vaultpolicy" "example" {
backup_vault_name = aws_backup_vault.example.name
policy = data.aws_iam_getpolicydocument.example.json
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.AwsFunctions;
import com.pulumi.aws.inputs.GetCallerIdentityArgs;
import com.pulumi.aws.backup.Vault;
import com.pulumi.aws.backup.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.GetPolicyDocumentStatementPrincipalArgs;
import com.pulumi.aws.backup.VaultPolicy;
import com.pulumi.aws.backup.VaultPolicyArgs;
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) {
final var current = AwsFunctions.getCallerIdentity(GetCallerIdentityArgs.builder()
.build());
var exampleVault = new Vault("exampleVault", VaultArgs.builder()
.name("example")
.build());
final var example = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
.statements(GetPolicyDocumentStatementArgs.builder()
.principals(GetPolicyDocumentStatementPrincipalArgs.builder()
.type("AWS")
.identifiers(current.accountId())
.build())
.effect("Allow")
.actions(
"backup:DescribeBackupVault",
"backup:DeleteBackupVault",
"backup:PutBackupVaultAccessPolicy",
"backup:DeleteBackupVaultAccessPolicy",
"backup:GetBackupVaultAccessPolicy",
"backup:StartBackupJob",
"backup:GetBackupVaultNotifications",
"backup:PutBackupVaultNotifications")
.resources(exampleVault.arn())
.build())
.build());
var exampleVaultPolicy = new VaultPolicy("exampleVaultPolicy", VaultPolicyArgs.builder()
.backupVaultName(exampleVault.name())
.policy(example.applyValue(_example -> _example.json()))
.build());
}
}
resources:
exampleVault:
type: aws:backup:Vault
name: example
properties:
name: example
exampleVaultPolicy:
type: aws:backup:VaultPolicy
name: example
properties:
backupVaultName: ${exampleVault.name}
policy: ${example.json}
variables:
current:
fn::invoke:
function: aws:getCallerIdentity
arguments: {}
example:
fn::invoke:
function: aws:iam:getPolicyDocument
arguments:
statements:
- principals:
- type: AWS
identifiers:
- ${current.accountId}
effect: Allow
actions:
- backup:DescribeBackupVault
- backup:DeleteBackupVault
- backup:PutBackupVaultAccessPolicy
- backup:DeleteBackupVaultAccessPolicy
- backup:GetBackupVaultAccessPolicy
- backup:StartBackupJob
- backup:GetBackupVaultNotifications
- backup:PutBackupVaultNotifications
resources:
- ${exampleVault.arn}
Import
Using pulumi import, import Backup vault policy using the name. For example:
$ pulumi import aws:backup/vaultPolicy:VaultPolicy test TestVault
Constructors
- VaultPolicy(String name, {VaultPolicyArgs? args, CustomResourceOptions? options})
-
Creates a new VaultPolicy.
nameThe Pulumi resource name.argsArguments used to configure this VaultPolicy. The set of arguments for VaultPolicy.optionsResource options controlling this resource's behavior. - VaultPolicy.reference(String urn)
- Creates a typed reference to an existing VaultPolicy resource.
Properties
-
backupVaultArn
↔ Output<
String> -
The ARN of the vault.
latefinal
-
backupVaultName
↔ Output<
String> -
Name of the backup vault to add policy for.
latefinal
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- 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> -
The backup vault access policy document in JSON format.
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
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, {VaultPolicyState? state, CustomResourceOptions? options}) → VaultPolicy -
Gets an existing VaultPolicy resource's state with the given
nameandid.