github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/redshiftserverless/resourcePolicy.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 redshiftserverless 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 // Creates a new Amazon Redshift Serverless Resource Policy. 16 // 17 // ## Example Usage 18 // 19 // <!--Start PulumiCodeChooser --> 20 // ```go 21 // package main 22 // 23 // import ( 24 // 25 // "encoding/json" 26 // 27 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/redshiftserverless" 28 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 29 // 30 // ) 31 // 32 // func main() { 33 // pulumi.Run(func(ctx *pulumi.Context) error { 34 // tmpJSON0, err := json.Marshal(map[string]interface{}{ 35 // "Version": "2012-10-17", 36 // "Statement": []map[string]interface{}{ 37 // map[string]interface{}{ 38 // "Effect": "Allow", 39 // "Principal": map[string]interface{}{ 40 // "AWS": []string{ 41 // "12345678901", 42 // }, 43 // }, 44 // "Action": []string{ 45 // "redshift-serverless:RestoreFromSnapshot", 46 // }, 47 // "Sid": "", 48 // }, 49 // }, 50 // }) 51 // if err != nil { 52 // return err 53 // } 54 // json0 := string(tmpJSON0) 55 // _, err = redshiftserverless.NewResourcePolicy(ctx, "example", &redshiftserverless.ResourcePolicyArgs{ 56 // ResourceArn: pulumi.Any(exampleAwsRedshiftserverlessSnapshot.Arn), 57 // Policy: pulumi.String(json0), 58 // }) 59 // if err != nil { 60 // return err 61 // } 62 // return nil 63 // }) 64 // } 65 // 66 // ``` 67 // <!--End PulumiCodeChooser --> 68 // 69 // ## Import 70 // 71 // Using `pulumi import`, import Redshift Serverless Resource Policies using the `resource_arn`. For example: 72 // 73 // ```sh 74 // $ pulumi import aws:redshiftserverless/resourcePolicy:ResourcePolicy example example 75 // ``` 76 type ResourcePolicy struct { 77 pulumi.CustomResourceState 78 79 // The policy to create or update. For example, the following policy grants a user authorization to restore a snapshot. 80 Policy pulumi.StringOutput `pulumi:"policy"` 81 // The Amazon Resource Name (ARN) of the account to create or update a resource policy for. 82 ResourceArn pulumi.StringOutput `pulumi:"resourceArn"` 83 } 84 85 // NewResourcePolicy registers a new resource with the given unique name, arguments, and options. 86 func NewResourcePolicy(ctx *pulumi.Context, 87 name string, args *ResourcePolicyArgs, opts ...pulumi.ResourceOption) (*ResourcePolicy, error) { 88 if args == nil { 89 return nil, errors.New("missing one or more required arguments") 90 } 91 92 if args.Policy == nil { 93 return nil, errors.New("invalid value for required argument 'Policy'") 94 } 95 if args.ResourceArn == nil { 96 return nil, errors.New("invalid value for required argument 'ResourceArn'") 97 } 98 opts = internal.PkgResourceDefaultOpts(opts) 99 var resource ResourcePolicy 100 err := ctx.RegisterResource("aws:redshiftserverless/resourcePolicy:ResourcePolicy", name, args, &resource, opts...) 101 if err != nil { 102 return nil, err 103 } 104 return &resource, nil 105 } 106 107 // GetResourcePolicy gets an existing ResourcePolicy resource's state with the given name, ID, and optional 108 // state properties that are used to uniquely qualify the lookup (nil if not required). 109 func GetResourcePolicy(ctx *pulumi.Context, 110 name string, id pulumi.IDInput, state *ResourcePolicyState, opts ...pulumi.ResourceOption) (*ResourcePolicy, error) { 111 var resource ResourcePolicy 112 err := ctx.ReadResource("aws:redshiftserverless/resourcePolicy:ResourcePolicy", name, id, state, &resource, opts...) 113 if err != nil { 114 return nil, err 115 } 116 return &resource, nil 117 } 118 119 // Input properties used for looking up and filtering ResourcePolicy resources. 120 type resourcePolicyState struct { 121 // The policy to create or update. For example, the following policy grants a user authorization to restore a snapshot. 122 Policy *string `pulumi:"policy"` 123 // The Amazon Resource Name (ARN) of the account to create or update a resource policy for. 124 ResourceArn *string `pulumi:"resourceArn"` 125 } 126 127 type ResourcePolicyState struct { 128 // The policy to create or update. For example, the following policy grants a user authorization to restore a snapshot. 129 Policy pulumi.StringPtrInput 130 // The Amazon Resource Name (ARN) of the account to create or update a resource policy for. 131 ResourceArn pulumi.StringPtrInput 132 } 133 134 func (ResourcePolicyState) ElementType() reflect.Type { 135 return reflect.TypeOf((*resourcePolicyState)(nil)).Elem() 136 } 137 138 type resourcePolicyArgs struct { 139 // The policy to create or update. For example, the following policy grants a user authorization to restore a snapshot. 140 Policy string `pulumi:"policy"` 141 // The Amazon Resource Name (ARN) of the account to create or update a resource policy for. 142 ResourceArn string `pulumi:"resourceArn"` 143 } 144 145 // The set of arguments for constructing a ResourcePolicy resource. 146 type ResourcePolicyArgs struct { 147 // The policy to create or update. For example, the following policy grants a user authorization to restore a snapshot. 148 Policy pulumi.StringInput 149 // The Amazon Resource Name (ARN) of the account to create or update a resource policy for. 150 ResourceArn pulumi.StringInput 151 } 152 153 func (ResourcePolicyArgs) ElementType() reflect.Type { 154 return reflect.TypeOf((*resourcePolicyArgs)(nil)).Elem() 155 } 156 157 type ResourcePolicyInput interface { 158 pulumi.Input 159 160 ToResourcePolicyOutput() ResourcePolicyOutput 161 ToResourcePolicyOutputWithContext(ctx context.Context) ResourcePolicyOutput 162 } 163 164 func (*ResourcePolicy) ElementType() reflect.Type { 165 return reflect.TypeOf((**ResourcePolicy)(nil)).Elem() 166 } 167 168 func (i *ResourcePolicy) ToResourcePolicyOutput() ResourcePolicyOutput { 169 return i.ToResourcePolicyOutputWithContext(context.Background()) 170 } 171 172 func (i *ResourcePolicy) ToResourcePolicyOutputWithContext(ctx context.Context) ResourcePolicyOutput { 173 return pulumi.ToOutputWithContext(ctx, i).(ResourcePolicyOutput) 174 } 175 176 // ResourcePolicyArrayInput is an input type that accepts ResourcePolicyArray and ResourcePolicyArrayOutput values. 177 // You can construct a concrete instance of `ResourcePolicyArrayInput` via: 178 // 179 // ResourcePolicyArray{ ResourcePolicyArgs{...} } 180 type ResourcePolicyArrayInput interface { 181 pulumi.Input 182 183 ToResourcePolicyArrayOutput() ResourcePolicyArrayOutput 184 ToResourcePolicyArrayOutputWithContext(context.Context) ResourcePolicyArrayOutput 185 } 186 187 type ResourcePolicyArray []ResourcePolicyInput 188 189 func (ResourcePolicyArray) ElementType() reflect.Type { 190 return reflect.TypeOf((*[]*ResourcePolicy)(nil)).Elem() 191 } 192 193 func (i ResourcePolicyArray) ToResourcePolicyArrayOutput() ResourcePolicyArrayOutput { 194 return i.ToResourcePolicyArrayOutputWithContext(context.Background()) 195 } 196 197 func (i ResourcePolicyArray) ToResourcePolicyArrayOutputWithContext(ctx context.Context) ResourcePolicyArrayOutput { 198 return pulumi.ToOutputWithContext(ctx, i).(ResourcePolicyArrayOutput) 199 } 200 201 // ResourcePolicyMapInput is an input type that accepts ResourcePolicyMap and ResourcePolicyMapOutput values. 202 // You can construct a concrete instance of `ResourcePolicyMapInput` via: 203 // 204 // ResourcePolicyMap{ "key": ResourcePolicyArgs{...} } 205 type ResourcePolicyMapInput interface { 206 pulumi.Input 207 208 ToResourcePolicyMapOutput() ResourcePolicyMapOutput 209 ToResourcePolicyMapOutputWithContext(context.Context) ResourcePolicyMapOutput 210 } 211 212 type ResourcePolicyMap map[string]ResourcePolicyInput 213 214 func (ResourcePolicyMap) ElementType() reflect.Type { 215 return reflect.TypeOf((*map[string]*ResourcePolicy)(nil)).Elem() 216 } 217 218 func (i ResourcePolicyMap) ToResourcePolicyMapOutput() ResourcePolicyMapOutput { 219 return i.ToResourcePolicyMapOutputWithContext(context.Background()) 220 } 221 222 func (i ResourcePolicyMap) ToResourcePolicyMapOutputWithContext(ctx context.Context) ResourcePolicyMapOutput { 223 return pulumi.ToOutputWithContext(ctx, i).(ResourcePolicyMapOutput) 224 } 225 226 type ResourcePolicyOutput struct{ *pulumi.OutputState } 227 228 func (ResourcePolicyOutput) ElementType() reflect.Type { 229 return reflect.TypeOf((**ResourcePolicy)(nil)).Elem() 230 } 231 232 func (o ResourcePolicyOutput) ToResourcePolicyOutput() ResourcePolicyOutput { 233 return o 234 } 235 236 func (o ResourcePolicyOutput) ToResourcePolicyOutputWithContext(ctx context.Context) ResourcePolicyOutput { 237 return o 238 } 239 240 // The policy to create or update. For example, the following policy grants a user authorization to restore a snapshot. 241 func (o ResourcePolicyOutput) Policy() pulumi.StringOutput { 242 return o.ApplyT(func(v *ResourcePolicy) pulumi.StringOutput { return v.Policy }).(pulumi.StringOutput) 243 } 244 245 // The Amazon Resource Name (ARN) of the account to create or update a resource policy for. 246 func (o ResourcePolicyOutput) ResourceArn() pulumi.StringOutput { 247 return o.ApplyT(func(v *ResourcePolicy) pulumi.StringOutput { return v.ResourceArn }).(pulumi.StringOutput) 248 } 249 250 type ResourcePolicyArrayOutput struct{ *pulumi.OutputState } 251 252 func (ResourcePolicyArrayOutput) ElementType() reflect.Type { 253 return reflect.TypeOf((*[]*ResourcePolicy)(nil)).Elem() 254 } 255 256 func (o ResourcePolicyArrayOutput) ToResourcePolicyArrayOutput() ResourcePolicyArrayOutput { 257 return o 258 } 259 260 func (o ResourcePolicyArrayOutput) ToResourcePolicyArrayOutputWithContext(ctx context.Context) ResourcePolicyArrayOutput { 261 return o 262 } 263 264 func (o ResourcePolicyArrayOutput) Index(i pulumi.IntInput) ResourcePolicyOutput { 265 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ResourcePolicy { 266 return vs[0].([]*ResourcePolicy)[vs[1].(int)] 267 }).(ResourcePolicyOutput) 268 } 269 270 type ResourcePolicyMapOutput struct{ *pulumi.OutputState } 271 272 func (ResourcePolicyMapOutput) ElementType() reflect.Type { 273 return reflect.TypeOf((*map[string]*ResourcePolicy)(nil)).Elem() 274 } 275 276 func (o ResourcePolicyMapOutput) ToResourcePolicyMapOutput() ResourcePolicyMapOutput { 277 return o 278 } 279 280 func (o ResourcePolicyMapOutput) ToResourcePolicyMapOutputWithContext(ctx context.Context) ResourcePolicyMapOutput { 281 return o 282 } 283 284 func (o ResourcePolicyMapOutput) MapIndex(k pulumi.StringInput) ResourcePolicyOutput { 285 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ResourcePolicy { 286 return vs[0].(map[string]*ResourcePolicy)[vs[1].(string)] 287 }).(ResourcePolicyOutput) 288 } 289 290 func init() { 291 pulumi.RegisterInputType(reflect.TypeOf((*ResourcePolicyInput)(nil)).Elem(), &ResourcePolicy{}) 292 pulumi.RegisterInputType(reflect.TypeOf((*ResourcePolicyArrayInput)(nil)).Elem(), ResourcePolicyArray{}) 293 pulumi.RegisterInputType(reflect.TypeOf((*ResourcePolicyMapInput)(nil)).Elem(), ResourcePolicyMap{}) 294 pulumi.RegisterOutputType(ResourcePolicyOutput{}) 295 pulumi.RegisterOutputType(ResourcePolicyArrayOutput{}) 296 pulumi.RegisterOutputType(ResourcePolicyMapOutput{}) 297 }