AWS Classic

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

VaultNotifications

Provides an AWS Backup vault notifications resource.

Example Usage

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

return await Deployment.RunAsync(() => 
{
    var testTopic = new Aws.Sns.Topic("testTopic");

    var testPolicyDocument = Aws.Iam.GetPolicyDocument.Invoke(new()
    {
        PolicyId = "__default_policy_ID",
        Statements = new[]
        {
            new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
            {
                Actions = new[]
                {
                    "SNS:Publish",
                },
                Effect = "Allow",
                Principals = new[]
                {
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                    {
                        Type = "Service",
                        Identifiers = new[]
                        {
                            "backup.amazonaws.com",
                        },
                    },
                },
                Resources = new[]
                {
                    testTopic.Arn,
                },
                Sid = "__default_statement_ID",
            },
        },
    });

    var testTopicPolicy = new Aws.Sns.TopicPolicy("testTopicPolicy", new()
    {
        Arn = testTopic.Arn,
        Policy = testPolicyDocument.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
    });

    var testVaultNotifications = new Aws.Backup.VaultNotifications("testVaultNotifications", new()
    {
        BackupVaultName = "example_backup_vault",
        SnsTopicArn = testTopic.Arn,
        BackupVaultEvents = new[]
        {
            "BACKUP_JOB_STARTED",
            "RESTORE_JOB_COMPLETED",
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/backup"
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/iam"
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/sns"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		testTopic, err := sns.NewTopic(ctx, "testTopic", nil)
		if err != nil {
			return err
		}
		_, err = sns.NewTopicPolicy(ctx, "testTopicPolicy", &sns.TopicPolicyArgs{
			Arn: testTopic.Arn,
			Policy: testPolicyDocument.ApplyT(func(testPolicyDocument iam.GetPolicyDocumentResult) (string, error) {
				return testPolicyDocument.Json, nil
			}).(pulumi.StringOutput),
		})
		if err != nil {
			return err
		}
		_, err = backup.NewVaultNotifications(ctx, "testVaultNotifications", &backup.VaultNotificationsArgs{
			BackupVaultName: pulumi.String("example_backup_vault"),
			SnsTopicArn:     testTopic.Arn,
			BackupVaultEvents: pulumi.StringArray{
				pulumi.String("BACKUP_JOB_STARTED"),
				pulumi.String("RESTORE_JOB_COMPLETED"),
			},
		})
		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.sns.Topic;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.sns.TopicPolicy;
import com.pulumi.aws.sns.TopicPolicyArgs;
import com.pulumi.aws.backup.VaultNotifications;
import com.pulumi.aws.backup.VaultNotificationsArgs;
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 testTopic = new Topic("testTopic");

        final var testPolicyDocument = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
            .policyId("__default_policy_ID")
            .statements(GetPolicyDocumentStatementArgs.builder()
                .actions("SNS:Publish")
                .effect("Allow")
                .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                    .type("Service")
                    .identifiers("backup.amazonaws.com")
                    .build())
                .resources(testTopic.arn())
                .sid("__default_statement_ID")
                .build())
            .build());

        var testTopicPolicy = new TopicPolicy("testTopicPolicy", TopicPolicyArgs.builder()        
            .arn(testTopic.arn())
            .policy(testPolicyDocument.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult).applyValue(testPolicyDocument -> testPolicyDocument.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.json())))
            .build());

        var testVaultNotifications = new VaultNotifications("testVaultNotifications", VaultNotificationsArgs.builder()        
            .backupVaultName("example_backup_vault")
            .snsTopicArn(testTopic.arn())
            .backupVaultEvents(            
                "BACKUP_JOB_STARTED",
                "RESTORE_JOB_COMPLETED")
            .build());

    }
}
import pulumi
import pulumi_aws as aws

test_topic = aws.sns.Topic("testTopic")
test_policy_document = test_topic.arn.apply(lambda arn: aws.iam.get_policy_document_output(policy_id="__default_policy_ID",
    statements=[aws.iam.GetPolicyDocumentStatementArgs(
        actions=["SNS:Publish"],
        effect="Allow",
        principals=[aws.iam.GetPolicyDocumentStatementPrincipalArgs(
            type="Service",
            identifiers=["backup.amazonaws.com"],
        )],
        resources=[arn],
        sid="__default_statement_ID",
    )]))
test_topic_policy = aws.sns.TopicPolicy("testTopicPolicy",
    arn=test_topic.arn,
    policy=test_policy_document.json)
test_vault_notifications = aws.backup.VaultNotifications("testVaultNotifications",
    backup_vault_name="example_backup_vault",
    sns_topic_arn=test_topic.arn,
    backup_vault_events=[
        "BACKUP_JOB_STARTED",
        "RESTORE_JOB_COMPLETED",
    ])
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const testTopic = new aws.sns.Topic("testTopic", {});
const testPolicyDocument = testTopic.arn.apply(arn => aws.iam.getPolicyDocumentOutput({
    policyId: "__default_policy_ID",
    statements: [{
        actions: ["SNS:Publish"],
        effect: "Allow",
        principals: [{
            type: "Service",
            identifiers: ["backup.amazonaws.com"],
        }],
        resources: [arn],
        sid: "__default_statement_ID",
    }],
}));
const testTopicPolicy = new aws.sns.TopicPolicy("testTopicPolicy", {
    arn: testTopic.arn,
    policy: testPolicyDocument.apply(testPolicyDocument => testPolicyDocument.json),
});
const testVaultNotifications = new aws.backup.VaultNotifications("testVaultNotifications", {
    backupVaultName: "example_backup_vault",
    snsTopicArn: testTopic.arn,
    backupVaultEvents: [
        "BACKUP_JOB_STARTED",
        "RESTORE_JOB_COMPLETED",
    ],
});
resources:
  testTopic:
    type: aws:sns:Topic
  testTopicPolicy:
    type: aws:sns:TopicPolicy
    properties:
      arn: ${testTopic.arn}
      policy: ${testPolicyDocument.json}
  testVaultNotifications:
    type: aws:backup:VaultNotifications
    properties:
      backupVaultName: example_backup_vault
      snsTopicArn: ${testTopic.arn}
      backupVaultEvents:
        - BACKUP_JOB_STARTED
        - RESTORE_JOB_COMPLETED
variables:
  testPolicyDocument:
    Fn::Invoke:
      Function: aws:iam:getPolicyDocument
      Arguments:
        policyId: __default_policy_ID
        statements:
          - actions:
              - SNS:Publish
            effect: Allow
            principals:
              - type: Service
                identifiers:
                  - backup.amazonaws.com
            resources:
              - ${testTopic.arn}
            sid: __default_statement_ID

Create a VaultNotifications Resource

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

name string
The unique name of the resource.
args VaultNotificationsArgs
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 VaultNotificationsArgs
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 VaultNotificationsArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args VaultNotificationsArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args VaultNotificationsArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

VaultNotifications 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 VaultNotifications resource accepts the following input properties:

BackupVaultEvents List<string>

An array of events that indicate the status of jobs to back up resources to the backup vault.

BackupVaultName string

Name of the backup vault to add notifications for.

SnsTopicArn string

The Amazon Resource Name (ARN) that specifies the topic for a backup vault’s events

BackupVaultEvents []string

An array of events that indicate the status of jobs to back up resources to the backup vault.

BackupVaultName string

Name of the backup vault to add notifications for.

SnsTopicArn string

The Amazon Resource Name (ARN) that specifies the topic for a backup vault’s events

backupVaultEvents List<String>

An array of events that indicate the status of jobs to back up resources to the backup vault.

backupVaultName String

Name of the backup vault to add notifications for.

snsTopicArn String

The Amazon Resource Name (ARN) that specifies the topic for a backup vault’s events

backupVaultEvents string[]

An array of events that indicate the status of jobs to back up resources to the backup vault.

backupVaultName string

Name of the backup vault to add notifications for.

snsTopicArn string

The Amazon Resource Name (ARN) that specifies the topic for a backup vault’s events

backup_vault_events Sequence[str]

An array of events that indicate the status of jobs to back up resources to the backup vault.

backup_vault_name str

Name of the backup vault to add notifications for.

sns_topic_arn str

The Amazon Resource Name (ARN) that specifies the topic for a backup vault’s events

backupVaultEvents List<String>

An array of events that indicate the status of jobs to back up resources to the backup vault.

backupVaultName String

Name of the backup vault to add notifications for.

snsTopicArn String

The Amazon Resource Name (ARN) that specifies the topic for a backup vault’s events

Outputs

All input properties are implicitly available as output properties. Additionally, the VaultNotifications 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 VaultNotifications Resource

Get an existing VaultNotifications 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?: VaultNotificationsState, opts?: CustomResourceOptions): VaultNotifications
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        backup_vault_arn: Optional[str] = None,
        backup_vault_events: Optional[Sequence[str]] = None,
        backup_vault_name: Optional[str] = None,
        sns_topic_arn: Optional[str] = None) -> VaultNotifications
func GetVaultNotifications(ctx *Context, name string, id IDInput, state *VaultNotificationsState, opts ...ResourceOption) (*VaultNotifications, error)
public static VaultNotifications Get(string name, Input<string> id, VaultNotificationsState? state, CustomResourceOptions? opts = null)
public static VaultNotifications get(String name, Output<String> id, VaultNotificationsState 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.

BackupVaultEvents List<string>

An array of events that indicate the status of jobs to back up resources to the backup vault.

BackupVaultName string

Name of the backup vault to add notifications for.

SnsTopicArn string

The Amazon Resource Name (ARN) that specifies the topic for a backup vault’s events

BackupVaultArn string

The ARN of the vault.

BackupVaultEvents []string

An array of events that indicate the status of jobs to back up resources to the backup vault.

BackupVaultName string

Name of the backup vault to add notifications for.

SnsTopicArn string

The Amazon Resource Name (ARN) that specifies the topic for a backup vault’s events

backupVaultArn String

The ARN of the vault.

backupVaultEvents List<String>

An array of events that indicate the status of jobs to back up resources to the backup vault.

backupVaultName String

Name of the backup vault to add notifications for.

snsTopicArn String

The Amazon Resource Name (ARN) that specifies the topic for a backup vault’s events

backupVaultArn string

The ARN of the vault.

backupVaultEvents string[]

An array of events that indicate the status of jobs to back up resources to the backup vault.

backupVaultName string

Name of the backup vault to add notifications for.

snsTopicArn string

The Amazon Resource Name (ARN) that specifies the topic for a backup vault’s events

backup_vault_arn str

The ARN of the vault.

backup_vault_events Sequence[str]

An array of events that indicate the status of jobs to back up resources to the backup vault.

backup_vault_name str

Name of the backup vault to add notifications for.

sns_topic_arn str

The Amazon Resource Name (ARN) that specifies the topic for a backup vault’s events

backupVaultArn String

The ARN of the vault.

backupVaultEvents List<String>

An array of events that indicate the status of jobs to back up resources to the backup vault.

backupVaultName String

Name of the backup vault to add notifications for.

snsTopicArn String

The Amazon Resource Name (ARN) that specifies the topic for a backup vault’s events

Import

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

 $ pulumi import aws:backup/vaultNotifications:VaultNotifications 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.