github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/iot/policyAttachment.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 iot 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 IoT policy attachment. 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/iam" 26 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iot" 27 // "github.com/pulumi/pulumi-std/sdk/go/std" 28 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 29 // 30 // ) 31 // 32 // func main() { 33 // pulumi.Run(func(ctx *pulumi.Context) error { 34 // pubsub, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{ 35 // Statements: []iam.GetPolicyDocumentStatement{ 36 // { 37 // Effect: pulumi.StringRef("Allow"), 38 // Actions: []string{ 39 // "iot:*", 40 // }, 41 // Resources: []string{ 42 // "*", 43 // }, 44 // }, 45 // }, 46 // }, nil) 47 // if err != nil { 48 // return err 49 // } 50 // pubsubPolicy, err := iot.NewPolicy(ctx, "pubsub", &iot.PolicyArgs{ 51 // Name: pulumi.String("PubSubToAnyTopic"), 52 // Policy: pulumi.String(pubsub.Json), 53 // }) 54 // if err != nil { 55 // return err 56 // } 57 // invokeFile, err := std.File(ctx, &std.FileArgs{ 58 // Input: "csr.pem", 59 // }, nil) 60 // if err != nil { 61 // return err 62 // } 63 // cert, err := iot.NewCertificate(ctx, "cert", &iot.CertificateArgs{ 64 // Csr: invokeFile.Result, 65 // Active: pulumi.Bool(true), 66 // }) 67 // if err != nil { 68 // return err 69 // } 70 // _, err = iot.NewPolicyAttachment(ctx, "att", &iot.PolicyAttachmentArgs{ 71 // Policy: pubsubPolicy.Name, 72 // Target: cert.Arn, 73 // }) 74 // if err != nil { 75 // return err 76 // } 77 // return nil 78 // }) 79 // } 80 // 81 // ``` 82 // <!--End PulumiCodeChooser --> 83 type PolicyAttachment struct { 84 pulumi.CustomResourceState 85 86 // The name of the policy to attach. 87 Policy pulumi.StringOutput `pulumi:"policy"` 88 // The identity to which the policy is attached. 89 Target pulumi.StringOutput `pulumi:"target"` 90 } 91 92 // NewPolicyAttachment registers a new resource with the given unique name, arguments, and options. 93 func NewPolicyAttachment(ctx *pulumi.Context, 94 name string, args *PolicyAttachmentArgs, opts ...pulumi.ResourceOption) (*PolicyAttachment, error) { 95 if args == nil { 96 return nil, errors.New("missing one or more required arguments") 97 } 98 99 if args.Policy == nil { 100 return nil, errors.New("invalid value for required argument 'Policy'") 101 } 102 if args.Target == nil { 103 return nil, errors.New("invalid value for required argument 'Target'") 104 } 105 opts = internal.PkgResourceDefaultOpts(opts) 106 var resource PolicyAttachment 107 err := ctx.RegisterResource("aws:iot/policyAttachment:PolicyAttachment", name, args, &resource, opts...) 108 if err != nil { 109 return nil, err 110 } 111 return &resource, nil 112 } 113 114 // GetPolicyAttachment gets an existing PolicyAttachment resource's state with the given name, ID, and optional 115 // state properties that are used to uniquely qualify the lookup (nil if not required). 116 func GetPolicyAttachment(ctx *pulumi.Context, 117 name string, id pulumi.IDInput, state *PolicyAttachmentState, opts ...pulumi.ResourceOption) (*PolicyAttachment, error) { 118 var resource PolicyAttachment 119 err := ctx.ReadResource("aws:iot/policyAttachment:PolicyAttachment", name, id, state, &resource, opts...) 120 if err != nil { 121 return nil, err 122 } 123 return &resource, nil 124 } 125 126 // Input properties used for looking up and filtering PolicyAttachment resources. 127 type policyAttachmentState struct { 128 // The name of the policy to attach. 129 Policy interface{} `pulumi:"policy"` 130 // The identity to which the policy is attached. 131 Target *string `pulumi:"target"` 132 } 133 134 type PolicyAttachmentState struct { 135 // The name of the policy to attach. 136 Policy pulumi.Input 137 // The identity to which the policy is attached. 138 Target pulumi.StringPtrInput 139 } 140 141 func (PolicyAttachmentState) ElementType() reflect.Type { 142 return reflect.TypeOf((*policyAttachmentState)(nil)).Elem() 143 } 144 145 type policyAttachmentArgs struct { 146 // The name of the policy to attach. 147 Policy interface{} `pulumi:"policy"` 148 // The identity to which the policy is attached. 149 Target string `pulumi:"target"` 150 } 151 152 // The set of arguments for constructing a PolicyAttachment resource. 153 type PolicyAttachmentArgs struct { 154 // The name of the policy to attach. 155 Policy pulumi.Input 156 // The identity to which the policy is attached. 157 Target pulumi.StringInput 158 } 159 160 func (PolicyAttachmentArgs) ElementType() reflect.Type { 161 return reflect.TypeOf((*policyAttachmentArgs)(nil)).Elem() 162 } 163 164 type PolicyAttachmentInput interface { 165 pulumi.Input 166 167 ToPolicyAttachmentOutput() PolicyAttachmentOutput 168 ToPolicyAttachmentOutputWithContext(ctx context.Context) PolicyAttachmentOutput 169 } 170 171 func (*PolicyAttachment) ElementType() reflect.Type { 172 return reflect.TypeOf((**PolicyAttachment)(nil)).Elem() 173 } 174 175 func (i *PolicyAttachment) ToPolicyAttachmentOutput() PolicyAttachmentOutput { 176 return i.ToPolicyAttachmentOutputWithContext(context.Background()) 177 } 178 179 func (i *PolicyAttachment) ToPolicyAttachmentOutputWithContext(ctx context.Context) PolicyAttachmentOutput { 180 return pulumi.ToOutputWithContext(ctx, i).(PolicyAttachmentOutput) 181 } 182 183 // PolicyAttachmentArrayInput is an input type that accepts PolicyAttachmentArray and PolicyAttachmentArrayOutput values. 184 // You can construct a concrete instance of `PolicyAttachmentArrayInput` via: 185 // 186 // PolicyAttachmentArray{ PolicyAttachmentArgs{...} } 187 type PolicyAttachmentArrayInput interface { 188 pulumi.Input 189 190 ToPolicyAttachmentArrayOutput() PolicyAttachmentArrayOutput 191 ToPolicyAttachmentArrayOutputWithContext(context.Context) PolicyAttachmentArrayOutput 192 } 193 194 type PolicyAttachmentArray []PolicyAttachmentInput 195 196 func (PolicyAttachmentArray) ElementType() reflect.Type { 197 return reflect.TypeOf((*[]*PolicyAttachment)(nil)).Elem() 198 } 199 200 func (i PolicyAttachmentArray) ToPolicyAttachmentArrayOutput() PolicyAttachmentArrayOutput { 201 return i.ToPolicyAttachmentArrayOutputWithContext(context.Background()) 202 } 203 204 func (i PolicyAttachmentArray) ToPolicyAttachmentArrayOutputWithContext(ctx context.Context) PolicyAttachmentArrayOutput { 205 return pulumi.ToOutputWithContext(ctx, i).(PolicyAttachmentArrayOutput) 206 } 207 208 // PolicyAttachmentMapInput is an input type that accepts PolicyAttachmentMap and PolicyAttachmentMapOutput values. 209 // You can construct a concrete instance of `PolicyAttachmentMapInput` via: 210 // 211 // PolicyAttachmentMap{ "key": PolicyAttachmentArgs{...} } 212 type PolicyAttachmentMapInput interface { 213 pulumi.Input 214 215 ToPolicyAttachmentMapOutput() PolicyAttachmentMapOutput 216 ToPolicyAttachmentMapOutputWithContext(context.Context) PolicyAttachmentMapOutput 217 } 218 219 type PolicyAttachmentMap map[string]PolicyAttachmentInput 220 221 func (PolicyAttachmentMap) ElementType() reflect.Type { 222 return reflect.TypeOf((*map[string]*PolicyAttachment)(nil)).Elem() 223 } 224 225 func (i PolicyAttachmentMap) ToPolicyAttachmentMapOutput() PolicyAttachmentMapOutput { 226 return i.ToPolicyAttachmentMapOutputWithContext(context.Background()) 227 } 228 229 func (i PolicyAttachmentMap) ToPolicyAttachmentMapOutputWithContext(ctx context.Context) PolicyAttachmentMapOutput { 230 return pulumi.ToOutputWithContext(ctx, i).(PolicyAttachmentMapOutput) 231 } 232 233 type PolicyAttachmentOutput struct{ *pulumi.OutputState } 234 235 func (PolicyAttachmentOutput) ElementType() reflect.Type { 236 return reflect.TypeOf((**PolicyAttachment)(nil)).Elem() 237 } 238 239 func (o PolicyAttachmentOutput) ToPolicyAttachmentOutput() PolicyAttachmentOutput { 240 return o 241 } 242 243 func (o PolicyAttachmentOutput) ToPolicyAttachmentOutputWithContext(ctx context.Context) PolicyAttachmentOutput { 244 return o 245 } 246 247 // The name of the policy to attach. 248 func (o PolicyAttachmentOutput) Policy() pulumi.StringOutput { 249 return o.ApplyT(func(v *PolicyAttachment) pulumi.StringOutput { return v.Policy }).(pulumi.StringOutput) 250 } 251 252 // The identity to which the policy is attached. 253 func (o PolicyAttachmentOutput) Target() pulumi.StringOutput { 254 return o.ApplyT(func(v *PolicyAttachment) pulumi.StringOutput { return v.Target }).(pulumi.StringOutput) 255 } 256 257 type PolicyAttachmentArrayOutput struct{ *pulumi.OutputState } 258 259 func (PolicyAttachmentArrayOutput) ElementType() reflect.Type { 260 return reflect.TypeOf((*[]*PolicyAttachment)(nil)).Elem() 261 } 262 263 func (o PolicyAttachmentArrayOutput) ToPolicyAttachmentArrayOutput() PolicyAttachmentArrayOutput { 264 return o 265 } 266 267 func (o PolicyAttachmentArrayOutput) ToPolicyAttachmentArrayOutputWithContext(ctx context.Context) PolicyAttachmentArrayOutput { 268 return o 269 } 270 271 func (o PolicyAttachmentArrayOutput) Index(i pulumi.IntInput) PolicyAttachmentOutput { 272 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *PolicyAttachment { 273 return vs[0].([]*PolicyAttachment)[vs[1].(int)] 274 }).(PolicyAttachmentOutput) 275 } 276 277 type PolicyAttachmentMapOutput struct{ *pulumi.OutputState } 278 279 func (PolicyAttachmentMapOutput) ElementType() reflect.Type { 280 return reflect.TypeOf((*map[string]*PolicyAttachment)(nil)).Elem() 281 } 282 283 func (o PolicyAttachmentMapOutput) ToPolicyAttachmentMapOutput() PolicyAttachmentMapOutput { 284 return o 285 } 286 287 func (o PolicyAttachmentMapOutput) ToPolicyAttachmentMapOutputWithContext(ctx context.Context) PolicyAttachmentMapOutput { 288 return o 289 } 290 291 func (o PolicyAttachmentMapOutput) MapIndex(k pulumi.StringInput) PolicyAttachmentOutput { 292 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *PolicyAttachment { 293 return vs[0].(map[string]*PolicyAttachment)[vs[1].(string)] 294 }).(PolicyAttachmentOutput) 295 } 296 297 func init() { 298 pulumi.RegisterInputType(reflect.TypeOf((*PolicyAttachmentInput)(nil)).Elem(), &PolicyAttachment{}) 299 pulumi.RegisterInputType(reflect.TypeOf((*PolicyAttachmentArrayInput)(nil)).Elem(), PolicyAttachmentArray{}) 300 pulumi.RegisterInputType(reflect.TypeOf((*PolicyAttachmentMapInput)(nil)).Elem(), PolicyAttachmentMap{}) 301 pulumi.RegisterOutputType(PolicyAttachmentOutput{}) 302 pulumi.RegisterOutputType(PolicyAttachmentArrayOutput{}) 303 pulumi.RegisterOutputType(PolicyAttachmentMapOutput{}) 304 }