AWS Classic

v5.16.0 published on Saturday, Sep 24, 2022 by Pulumi

VaultPolicy

Provides an AWS Backup vault policy resource.

Example Usage

using System.Collections.Generic;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var exampleVault = new Aws.Backup.Vault("exampleVault");

    var exampleVaultPolicy = new Aws.Backup.VaultPolicy("exampleVaultPolicy", new()
    {
        BackupVaultName = exampleVault.Name,
        Policy = exampleVault.Arn.Apply(arn => @$"{{
  ""Version"": ""2012-10-17"",
  ""Id"": ""default"",
  ""Statement"": [
    {{
      ""Sid"": ""default"",
      ""Effect"": ""Allow"",
      ""Principal"": {{
        ""AWS"": ""*""
      }},
      ""Action"": [
		""backup:DescribeBackupVault"",
		""backup:DeleteBackupVault"",
		""backup:PutBackupVaultAccessPolicy"",
		""backup:DeleteBackupVaultAccessPolicy"",
		""backup:GetBackupVaultAccessPolicy"",
		""backup:StartBackupJob"",
		""backup:GetBackupVaultNotifications"",
		""backup:PutBackupVaultNotifications""
      ],
      ""Resource"": ""{arn}""
    }}
  ]
}}
"),
    });

});
package main

import (
	"fmt"

	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/backup"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		exampleVault, err := backup.NewVault(ctx, "exampleVault", nil)
		if err != nil {
			return err
		}
		_, err = backup.NewVaultPolicy(ctx, "exampleVaultPolicy", &backup.VaultPolicyArgs{
			BackupVaultName: exampleVault.Name,
			Policy: exampleVault.Arn.ApplyT(func(arn string) (string, error) {
				return fmt.Sprintf(`{
  "Version": "2012-10-17",
  "Id": "default",
  "Statement": [
    {
      "Sid": "default",
      "Effect": "Allow",
      "Principal": {
        "AWS": "*"
      },
      "Action": [
		"backup:DescribeBackupVault",
		"backup:DeleteBackupVault",
		"backup:PutBackupVaultAccessPolicy",
		"backup:DeleteBackupVaultAccessPolicy",
		"backup:GetBackupVaultAccessPolicy",
		"backup:StartBackupJob",
		"backup:GetBackupVaultNotifications",
		"backup:PutBackupVaultNotifications"
      ],
      "Resource": "%v"
    }
  ]
}
`, arn), nil
			}).(pulumi.StringOutput),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.backup.Vault;
import com.pulumi.aws.backup.VaultPolicy;
import com.pulumi.aws.backup.VaultPolicyArgs;
import java.util.List;
import java.util.ArrayList;
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");

        var exampleVaultPolicy = new VaultPolicy("exampleVaultPolicy", VaultPolicyArgs.builder()        
            .backupVaultName(exampleVault.name())
            .policy(exampleVault.arn().applyValue(arn -> """
{
  "Version": "2012-10-17",
  "Id": "default",
  "Statement": [
    {
      "Sid": "default",
      "Effect": "Allow",
      "Principal": {
        "AWS": "*"
      },
      "Action": [
		"backup:DescribeBackupVault",
		"backup:DeleteBackupVault",
		"backup:PutBackupVaultAccessPolicy",
		"backup:DeleteBackupVaultAccessPolicy",
		"backup:GetBackupVaultAccessPolicy",
		"backup:StartBackupJob",
		"backup:GetBackupVaultNotifications",
		"backup:PutBackupVaultNotifications"
      ],
      "Resource": "%s"
    }
  ]
}
", arn)))
            .build());

    }
}
import pulumi
import pulumi_aws as aws

example_vault = aws.backup.Vault("exampleVault")
example_vault_policy = aws.backup.VaultPolicy("exampleVaultPolicy",
    backup_vault_name=example_vault.name,
    policy=example_vault.arn.apply(lambda arn: f"""{{
  "Version": "2012-10-17",
  "Id": "default",
  "Statement": [
    {{
      "Sid": "default",
      "Effect": "Allow",
      "Principal": {{
        "AWS": "*"
      }},
      "Action": [
		"backup:DescribeBackupVault",
		"backup:DeleteBackupVault",
		"backup:PutBackupVaultAccessPolicy",
		"backup:DeleteBackupVaultAccessPolicy",
		"backup:GetBackupVaultAccessPolicy",
		"backup:StartBackupJob",
		"backup:GetBackupVaultNotifications",
		"backup:PutBackupVaultNotifications"
      ],
      "Resource": "{arn}"
    }}
  ]
}}
"""))
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const exampleVault = new aws.backup.Vault("exampleVault", {});
const exampleVaultPolicy = new aws.backup.VaultPolicy("exampleVaultPolicy", {
    backupVaultName: exampleVault.name,
    policy: pulumi.interpolate`{
  "Version": "2012-10-17",
  "Id": "default",
  "Statement": [
    {
      "Sid": "default",
      "Effect": "Allow",
      "Principal": {
        "AWS": "*"
      },
      "Action": [
		"backup:DescribeBackupVault",
		"backup:DeleteBackupVault",
		"backup:PutBackupVaultAccessPolicy",
		"backup:DeleteBackupVaultAccessPolicy",
		"backup:GetBackupVaultAccessPolicy",
		"backup:StartBackupJob",
		"backup:GetBackupVaultNotifications",
		"backup:PutBackupVaultNotifications"
      ],
      "Resource": "${exampleVault.arn}"
    }
  ]
}
`,
});
resources:
  exampleVault:
    type: aws:backup:Vault
  exampleVaultPolicy:
    type: aws:backup:VaultPolicy
    properties:
      backupVaultName: ${exampleVault.name}
      policy: |
        {
          "Version": "2012-10-17",
          "Id": "default",
          "Statement": [
            {
              "Sid": "default",
              "Effect": "Allow",
              "Principal": {
                "AWS": "*"
              },
              "Action": [
        		"backup:DescribeBackupVault",
        		"backup:DeleteBackupVault",
        		"backup:PutBackupVaultAccessPolicy",
        		"backup:DeleteBackupVaultAccessPolicy",
        		"backup:GetBackupVaultAccessPolicy",
        		"backup:StartBackupJob",
        		"backup:GetBackupVaultNotifications",
        		"backup:PutBackupVaultNotifications"
              ],
              "Resource": "${exampleVault.arn}"
            }
          ]
        }        

Create a VaultPolicy Resource

new VaultPolicy(name: string, args: VaultPolicyArgs, opts?: CustomResourceOptions);
@overload
def VaultPolicy(resource_name: str,
                opts: Optional[ResourceOptions] = None,
                backup_vault_name: Optional[str] = None,
                policy: Optional[str] = None)
@overload
def VaultPolicy(resource_name: str,
                args: VaultPolicyArgs,
                opts: Optional[ResourceOptions] = None)
func NewVaultPolicy(ctx *Context, name string, args VaultPolicyArgs, opts ...ResourceOption) (*VaultPolicy, error)
public VaultPolicy(string name, VaultPolicyArgs args, CustomResourceOptions? opts = null)
public VaultPolicy(String name, VaultPolicyArgs args)
public VaultPolicy(String name, VaultPolicyArgs args, CustomResourceOptions options)
type: aws:backup:VaultPolicy
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args VaultPolicyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args VaultPolicyArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args VaultPolicyArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args VaultPolicyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args VaultPolicyArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

VaultPolicy Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The VaultPolicy resource accepts the following input properties:

BackupVaultName string

Name of the backup vault to add policy for.

Policy string

The backup vault access policy document in JSON format.

BackupVaultName string

Name of the backup vault to add policy for.

Policy string

The backup vault access policy document in JSON format.

backupVaultName String

Name of the backup vault to add policy for.

policy String

The backup vault access policy document in JSON format.

backupVaultName string

Name of the backup vault to add policy for.

policy string

The backup vault access policy document in JSON format.

backup_vault_name str

Name of the backup vault to add policy for.

policy str

The backup vault access policy document in JSON format.

backupVaultName String

Name of the backup vault to add policy for.

policy String

The backup vault access policy document in JSON format.

Outputs

All input properties are implicitly available as output properties. Additionally, the VaultPolicy resource produces the following output properties:

BackupVaultArn string

The ARN of the vault.

Id string

The provider-assigned unique ID for this managed resource.

BackupVaultArn string

The ARN of the vault.

Id string

The provider-assigned unique ID for this managed resource.

backupVaultArn String

The ARN of the vault.

id String

The provider-assigned unique ID for this managed resource.

backupVaultArn string

The ARN of the vault.

id string

The provider-assigned unique ID for this managed resource.

backup_vault_arn str

The ARN of the vault.

id str

The provider-assigned unique ID for this managed resource.

backupVaultArn String

The ARN of the vault.

id String

The provider-assigned unique ID for this managed resource.

Look up an Existing VaultPolicy Resource

Get an existing VaultPolicy resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: VaultPolicyState, opts?: CustomResourceOptions): VaultPolicy
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        backup_vault_arn: Optional[str] = None,
        backup_vault_name: Optional[str] = None,
        policy: Optional[str] = None) -> VaultPolicy
func GetVaultPolicy(ctx *Context, name string, id IDInput, state *VaultPolicyState, opts ...ResourceOption) (*VaultPolicy, error)
public static VaultPolicy Get(string name, Input<string> id, VaultPolicyState? state, CustomResourceOptions? opts = null)
public static VaultPolicy get(String name, Output<String> id, VaultPolicyState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
BackupVaultArn string

The ARN of the vault.

BackupVaultName string

Name of the backup vault to add policy for.

Policy string

The backup vault access policy document in JSON format.

BackupVaultArn string

The ARN of the vault.

BackupVaultName string

Name of the backup vault to add policy for.

Policy string

The backup vault access policy document in JSON format.

backupVaultArn String

The ARN of the vault.

backupVaultName String

Name of the backup vault to add policy for.

policy String

The backup vault access policy document in JSON format.

backupVaultArn string

The ARN of the vault.

backupVaultName string

Name of the backup vault to add policy for.

policy string

The backup vault access policy document in JSON format.

backup_vault_arn str

The ARN of the vault.

backup_vault_name str

Name of the backup vault to add policy for.

policy str

The backup vault access policy document in JSON format.

backupVaultArn String

The ARN of the vault.

backupVaultName String

Name of the backup vault to add policy for.

policy String

The backup vault access policy document in JSON format.

Import

Backup vault policy can be imported using the name, e.g.,

 $ pulumi import aws:backup/vaultPolicy:VaultPolicy test TestVault

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes

This Pulumi package is based on the aws Terraform Provider.