github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/backup/vaultNotifications.go (about) 1 // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT. 2 // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 4 package backup 5 6 import ( 7 "context" 8 "reflect" 9 10 "errors" 11 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 12 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 13 ) 14 15 // Provides an AWS Backup vault notifications resource. 16 // 17 // ## Example Usage 18 // 19 // <!--Start PulumiCodeChooser --> 20 // ```go 21 // package main 22 // 23 // import ( 24 // 25 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/backup" 26 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam" 27 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/sns" 28 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 29 // 30 // ) 31 // func main() { 32 // pulumi.Run(func(ctx *pulumi.Context) error { 33 // testTopic, err := sns.NewTopic(ctx, "test", &sns.TopicArgs{ 34 // Name: pulumi.String("backup-vault-events"), 35 // }) 36 // if err != nil { 37 // return err 38 // } 39 // test := testTopic.Arn.ApplyT(func(arn string) (iam.GetPolicyDocumentResult, error) { 40 // return iam.GetPolicyDocumentOutput(ctx, iam.GetPolicyDocumentOutputArgs{ 41 // PolicyId: "__default_policy_ID", 42 // Statements: []iam.GetPolicyDocumentStatement{ 43 // { 44 // Actions: []string{ 45 // "SNS:Publish", 46 // }, 47 // Effect: "Allow", 48 // Principals: []iam.GetPolicyDocumentStatementPrincipal{ 49 // { 50 // Type: "Service", 51 // Identifiers: []string{ 52 // "backup.amazonaws.com", 53 // }, 54 // }, 55 // }, 56 // Resources: interface{}{ 57 // arn, 58 // }, 59 // Sid: "__default_statement_ID", 60 // }, 61 // }, 62 // }, nil), nil 63 // }).(iam.GetPolicyDocumentResultOutput) 64 // _, err = sns.NewTopicPolicy(ctx, "test", &sns.TopicPolicyArgs{ 65 // Arn: testTopic.Arn, 66 // Policy: test.ApplyT(func(test iam.GetPolicyDocumentResult) (*string, error) { 67 // return &test.Json, nil 68 // }).(pulumi.StringPtrOutput), 69 // }) 70 // if err != nil { 71 // return err 72 // } 73 // _, err = backup.NewVaultNotifications(ctx, "test", &backup.VaultNotificationsArgs{ 74 // BackupVaultName: pulumi.String("example_backup_vault"), 75 // SnsTopicArn: testTopic.Arn, 76 // BackupVaultEvents: pulumi.StringArray{ 77 // pulumi.String("BACKUP_JOB_STARTED"), 78 // pulumi.String("RESTORE_JOB_COMPLETED"), 79 // }, 80 // }) 81 // if err != nil { 82 // return err 83 // } 84 // return nil 85 // }) 86 // } 87 // ``` 88 // <!--End PulumiCodeChooser --> 89 // 90 // ## Import 91 // 92 // Using `pulumi import`, import Backup vault notifications using the `name`. For example: 93 // 94 // ```sh 95 // $ pulumi import aws:backup/vaultNotifications:VaultNotifications test TestVault 96 // ``` 97 type VaultNotifications struct { 98 pulumi.CustomResourceState 99 100 // The ARN of the vault. 101 BackupVaultArn pulumi.StringOutput `pulumi:"backupVaultArn"` 102 // An array of events that indicate the status of jobs to back up resources to the backup vault. 103 BackupVaultEvents pulumi.StringArrayOutput `pulumi:"backupVaultEvents"` 104 // Name of the backup vault to add notifications for. 105 BackupVaultName pulumi.StringOutput `pulumi:"backupVaultName"` 106 // The Amazon Resource Name (ARN) that specifies the topic for a backup vault’s events 107 SnsTopicArn pulumi.StringOutput `pulumi:"snsTopicArn"` 108 } 109 110 // NewVaultNotifications registers a new resource with the given unique name, arguments, and options. 111 func NewVaultNotifications(ctx *pulumi.Context, 112 name string, args *VaultNotificationsArgs, opts ...pulumi.ResourceOption) (*VaultNotifications, error) { 113 if args == nil { 114 return nil, errors.New("missing one or more required arguments") 115 } 116 117 if args.BackupVaultEvents == nil { 118 return nil, errors.New("invalid value for required argument 'BackupVaultEvents'") 119 } 120 if args.BackupVaultName == nil { 121 return nil, errors.New("invalid value for required argument 'BackupVaultName'") 122 } 123 if args.SnsTopicArn == nil { 124 return nil, errors.New("invalid value for required argument 'SnsTopicArn'") 125 } 126 opts = internal.PkgResourceDefaultOpts(opts) 127 var resource VaultNotifications 128 err := ctx.RegisterResource("aws:backup/vaultNotifications:VaultNotifications", name, args, &resource, opts...) 129 if err != nil { 130 return nil, err 131 } 132 return &resource, nil 133 } 134 135 // GetVaultNotifications gets an existing VaultNotifications resource's state with the given name, ID, and optional 136 // state properties that are used to uniquely qualify the lookup (nil if not required). 137 func GetVaultNotifications(ctx *pulumi.Context, 138 name string, id pulumi.IDInput, state *VaultNotificationsState, opts ...pulumi.ResourceOption) (*VaultNotifications, error) { 139 var resource VaultNotifications 140 err := ctx.ReadResource("aws:backup/vaultNotifications:VaultNotifications", name, id, state, &resource, opts...) 141 if err != nil { 142 return nil, err 143 } 144 return &resource, nil 145 } 146 147 // Input properties used for looking up and filtering VaultNotifications resources. 148 type vaultNotificationsState struct { 149 // The ARN of the vault. 150 BackupVaultArn *string `pulumi:"backupVaultArn"` 151 // An array of events that indicate the status of jobs to back up resources to the backup vault. 152 BackupVaultEvents []string `pulumi:"backupVaultEvents"` 153 // Name of the backup vault to add notifications for. 154 BackupVaultName *string `pulumi:"backupVaultName"` 155 // The Amazon Resource Name (ARN) that specifies the topic for a backup vault’s events 156 SnsTopicArn *string `pulumi:"snsTopicArn"` 157 } 158 159 type VaultNotificationsState struct { 160 // The ARN of the vault. 161 BackupVaultArn pulumi.StringPtrInput 162 // An array of events that indicate the status of jobs to back up resources to the backup vault. 163 BackupVaultEvents pulumi.StringArrayInput 164 // Name of the backup vault to add notifications for. 165 BackupVaultName pulumi.StringPtrInput 166 // The Amazon Resource Name (ARN) that specifies the topic for a backup vault’s events 167 SnsTopicArn pulumi.StringPtrInput 168 } 169 170 func (VaultNotificationsState) ElementType() reflect.Type { 171 return reflect.TypeOf((*vaultNotificationsState)(nil)).Elem() 172 } 173 174 type vaultNotificationsArgs struct { 175 // An array of events that indicate the status of jobs to back up resources to the backup vault. 176 BackupVaultEvents []string `pulumi:"backupVaultEvents"` 177 // Name of the backup vault to add notifications for. 178 BackupVaultName string `pulumi:"backupVaultName"` 179 // The Amazon Resource Name (ARN) that specifies the topic for a backup vault’s events 180 SnsTopicArn string `pulumi:"snsTopicArn"` 181 } 182 183 // The set of arguments for constructing a VaultNotifications resource. 184 type VaultNotificationsArgs struct { 185 // An array of events that indicate the status of jobs to back up resources to the backup vault. 186 BackupVaultEvents pulumi.StringArrayInput 187 // Name of the backup vault to add notifications for. 188 BackupVaultName pulumi.StringInput 189 // The Amazon Resource Name (ARN) that specifies the topic for a backup vault’s events 190 SnsTopicArn pulumi.StringInput 191 } 192 193 func (VaultNotificationsArgs) ElementType() reflect.Type { 194 return reflect.TypeOf((*vaultNotificationsArgs)(nil)).Elem() 195 } 196 197 type VaultNotificationsInput interface { 198 pulumi.Input 199 200 ToVaultNotificationsOutput() VaultNotificationsOutput 201 ToVaultNotificationsOutputWithContext(ctx context.Context) VaultNotificationsOutput 202 } 203 204 func (*VaultNotifications) ElementType() reflect.Type { 205 return reflect.TypeOf((**VaultNotifications)(nil)).Elem() 206 } 207 208 func (i *VaultNotifications) ToVaultNotificationsOutput() VaultNotificationsOutput { 209 return i.ToVaultNotificationsOutputWithContext(context.Background()) 210 } 211 212 func (i *VaultNotifications) ToVaultNotificationsOutputWithContext(ctx context.Context) VaultNotificationsOutput { 213 return pulumi.ToOutputWithContext(ctx, i).(VaultNotificationsOutput) 214 } 215 216 // VaultNotificationsArrayInput is an input type that accepts VaultNotificationsArray and VaultNotificationsArrayOutput values. 217 // You can construct a concrete instance of `VaultNotificationsArrayInput` via: 218 // 219 // VaultNotificationsArray{ VaultNotificationsArgs{...} } 220 type VaultNotificationsArrayInput interface { 221 pulumi.Input 222 223 ToVaultNotificationsArrayOutput() VaultNotificationsArrayOutput 224 ToVaultNotificationsArrayOutputWithContext(context.Context) VaultNotificationsArrayOutput 225 } 226 227 type VaultNotificationsArray []VaultNotificationsInput 228 229 func (VaultNotificationsArray) ElementType() reflect.Type { 230 return reflect.TypeOf((*[]*VaultNotifications)(nil)).Elem() 231 } 232 233 func (i VaultNotificationsArray) ToVaultNotificationsArrayOutput() VaultNotificationsArrayOutput { 234 return i.ToVaultNotificationsArrayOutputWithContext(context.Background()) 235 } 236 237 func (i VaultNotificationsArray) ToVaultNotificationsArrayOutputWithContext(ctx context.Context) VaultNotificationsArrayOutput { 238 return pulumi.ToOutputWithContext(ctx, i).(VaultNotificationsArrayOutput) 239 } 240 241 // VaultNotificationsMapInput is an input type that accepts VaultNotificationsMap and VaultNotificationsMapOutput values. 242 // You can construct a concrete instance of `VaultNotificationsMapInput` via: 243 // 244 // VaultNotificationsMap{ "key": VaultNotificationsArgs{...} } 245 type VaultNotificationsMapInput interface { 246 pulumi.Input 247 248 ToVaultNotificationsMapOutput() VaultNotificationsMapOutput 249 ToVaultNotificationsMapOutputWithContext(context.Context) VaultNotificationsMapOutput 250 } 251 252 type VaultNotificationsMap map[string]VaultNotificationsInput 253 254 func (VaultNotificationsMap) ElementType() reflect.Type { 255 return reflect.TypeOf((*map[string]*VaultNotifications)(nil)).Elem() 256 } 257 258 func (i VaultNotificationsMap) ToVaultNotificationsMapOutput() VaultNotificationsMapOutput { 259 return i.ToVaultNotificationsMapOutputWithContext(context.Background()) 260 } 261 262 func (i VaultNotificationsMap) ToVaultNotificationsMapOutputWithContext(ctx context.Context) VaultNotificationsMapOutput { 263 return pulumi.ToOutputWithContext(ctx, i).(VaultNotificationsMapOutput) 264 } 265 266 type VaultNotificationsOutput struct{ *pulumi.OutputState } 267 268 func (VaultNotificationsOutput) ElementType() reflect.Type { 269 return reflect.TypeOf((**VaultNotifications)(nil)).Elem() 270 } 271 272 func (o VaultNotificationsOutput) ToVaultNotificationsOutput() VaultNotificationsOutput { 273 return o 274 } 275 276 func (o VaultNotificationsOutput) ToVaultNotificationsOutputWithContext(ctx context.Context) VaultNotificationsOutput { 277 return o 278 } 279 280 // The ARN of the vault. 281 func (o VaultNotificationsOutput) BackupVaultArn() pulumi.StringOutput { 282 return o.ApplyT(func(v *VaultNotifications) pulumi.StringOutput { return v.BackupVaultArn }).(pulumi.StringOutput) 283 } 284 285 // An array of events that indicate the status of jobs to back up resources to the backup vault. 286 func (o VaultNotificationsOutput) BackupVaultEvents() pulumi.StringArrayOutput { 287 return o.ApplyT(func(v *VaultNotifications) pulumi.StringArrayOutput { return v.BackupVaultEvents }).(pulumi.StringArrayOutput) 288 } 289 290 // Name of the backup vault to add notifications for. 291 func (o VaultNotificationsOutput) BackupVaultName() pulumi.StringOutput { 292 return o.ApplyT(func(v *VaultNotifications) pulumi.StringOutput { return v.BackupVaultName }).(pulumi.StringOutput) 293 } 294 295 // The Amazon Resource Name (ARN) that specifies the topic for a backup vault’s events 296 func (o VaultNotificationsOutput) SnsTopicArn() pulumi.StringOutput { 297 return o.ApplyT(func(v *VaultNotifications) pulumi.StringOutput { return v.SnsTopicArn }).(pulumi.StringOutput) 298 } 299 300 type VaultNotificationsArrayOutput struct{ *pulumi.OutputState } 301 302 func (VaultNotificationsArrayOutput) ElementType() reflect.Type { 303 return reflect.TypeOf((*[]*VaultNotifications)(nil)).Elem() 304 } 305 306 func (o VaultNotificationsArrayOutput) ToVaultNotificationsArrayOutput() VaultNotificationsArrayOutput { 307 return o 308 } 309 310 func (o VaultNotificationsArrayOutput) ToVaultNotificationsArrayOutputWithContext(ctx context.Context) VaultNotificationsArrayOutput { 311 return o 312 } 313 314 func (o VaultNotificationsArrayOutput) Index(i pulumi.IntInput) VaultNotificationsOutput { 315 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *VaultNotifications { 316 return vs[0].([]*VaultNotifications)[vs[1].(int)] 317 }).(VaultNotificationsOutput) 318 } 319 320 type VaultNotificationsMapOutput struct{ *pulumi.OutputState } 321 322 func (VaultNotificationsMapOutput) ElementType() reflect.Type { 323 return reflect.TypeOf((*map[string]*VaultNotifications)(nil)).Elem() 324 } 325 326 func (o VaultNotificationsMapOutput) ToVaultNotificationsMapOutput() VaultNotificationsMapOutput { 327 return o 328 } 329 330 func (o VaultNotificationsMapOutput) ToVaultNotificationsMapOutputWithContext(ctx context.Context) VaultNotificationsMapOutput { 331 return o 332 } 333 334 func (o VaultNotificationsMapOutput) MapIndex(k pulumi.StringInput) VaultNotificationsOutput { 335 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *VaultNotifications { 336 return vs[0].(map[string]*VaultNotifications)[vs[1].(string)] 337 }).(VaultNotificationsOutput) 338 } 339 340 func init() { 341 pulumi.RegisterInputType(reflect.TypeOf((*VaultNotificationsInput)(nil)).Elem(), &VaultNotifications{}) 342 pulumi.RegisterInputType(reflect.TypeOf((*VaultNotificationsArrayInput)(nil)).Elem(), VaultNotificationsArray{}) 343 pulumi.RegisterInputType(reflect.TypeOf((*VaultNotificationsMapInput)(nil)).Elem(), VaultNotificationsMap{}) 344 pulumi.RegisterOutputType(VaultNotificationsOutput{}) 345 pulumi.RegisterOutputType(VaultNotificationsArrayOutput{}) 346 pulumi.RegisterOutputType(VaultNotificationsMapOutput{}) 347 }