github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/cfg/recorderStatus.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 cfg 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 // Manages status (recording / stopped) of an AWS Config Configuration Recorder. 16 // 17 // > **Note:** Starting Configuration Recorder requires a Delivery Channel to be present. Use of `dependsOn` (as shown below) is recommended to avoid race conditions. 18 // 19 // ## Example Usage 20 // 21 // <!--Start PulumiCodeChooser --> 22 // ```go 23 // package main 24 // 25 // import ( 26 // 27 // "fmt" 28 // 29 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cfg" 30 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam" 31 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3" 32 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 33 // 34 // ) 35 // 36 // func main() { 37 // pulumi.Run(func(ctx *pulumi.Context) error { 38 // b, err := s3.NewBucketV2(ctx, "b", &s3.BucketV2Args{ 39 // Bucket: pulumi.String("awsconfig-example"), 40 // }) 41 // if err != nil { 42 // return err 43 // } 44 // fooDeliveryChannel, err := cfg.NewDeliveryChannel(ctx, "foo", &cfg.DeliveryChannelArgs{ 45 // Name: pulumi.String("example"), 46 // S3BucketName: b.Bucket, 47 // }) 48 // if err != nil { 49 // return err 50 // } 51 // assumeRole, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{ 52 // Statements: []iam.GetPolicyDocumentStatement{ 53 // { 54 // Effect: pulumi.StringRef("Allow"), 55 // Principals: []iam.GetPolicyDocumentStatementPrincipal{ 56 // { 57 // Type: "Service", 58 // Identifiers: []string{ 59 // "config.amazonaws.com", 60 // }, 61 // }, 62 // }, 63 // Actions: []string{ 64 // "sts:AssumeRole", 65 // }, 66 // }, 67 // }, 68 // }, nil) 69 // if err != nil { 70 // return err 71 // } 72 // r, err := iam.NewRole(ctx, "r", &iam.RoleArgs{ 73 // Name: pulumi.String("example-awsconfig"), 74 // AssumeRolePolicy: pulumi.String(assumeRole.Json), 75 // }) 76 // if err != nil { 77 // return err 78 // } 79 // fooRecorder, err := cfg.NewRecorder(ctx, "foo", &cfg.RecorderArgs{ 80 // Name: pulumi.String("example"), 81 // RoleArn: r.Arn, 82 // }) 83 // if err != nil { 84 // return err 85 // } 86 // _, err = cfg.NewRecorderStatus(ctx, "foo", &cfg.RecorderStatusArgs{ 87 // Name: fooRecorder.Name, 88 // IsEnabled: pulumi.Bool(true), 89 // }, pulumi.DependsOn([]pulumi.Resource{ 90 // fooDeliveryChannel, 91 // })) 92 // if err != nil { 93 // return err 94 // } 95 // _, err = iam.NewRolePolicyAttachment(ctx, "a", &iam.RolePolicyAttachmentArgs{ 96 // Role: r.Name, 97 // PolicyArn: pulumi.String("arn:aws:iam::aws:policy/service-role/AWS_ConfigRole"), 98 // }) 99 // if err != nil { 100 // return err 101 // } 102 // p := iam.GetPolicyDocumentOutput(ctx, iam.GetPolicyDocumentOutputArgs{ 103 // Statements: iam.GetPolicyDocumentStatementArray{ 104 // &iam.GetPolicyDocumentStatementArgs{ 105 // Effect: pulumi.String("Allow"), 106 // Actions: pulumi.StringArray{ 107 // pulumi.String("s3:*"), 108 // }, 109 // Resources: pulumi.StringArray{ 110 // b.Arn, 111 // b.Arn.ApplyT(func(arn string) (string, error) { 112 // return fmt.Sprintf("%v/*", arn), nil 113 // }).(pulumi.StringOutput), 114 // }, 115 // }, 116 // }, 117 // }, nil) 118 // _, err = iam.NewRolePolicy(ctx, "p", &iam.RolePolicyArgs{ 119 // Name: pulumi.String("awsconfig-example"), 120 // Role: r.ID(), 121 // Policy: p.ApplyT(func(p iam.GetPolicyDocumentResult) (*string, error) { 122 // return &p.Json, nil 123 // }).(pulumi.StringPtrOutput), 124 // }) 125 // if err != nil { 126 // return err 127 // } 128 // return nil 129 // }) 130 // } 131 // 132 // ``` 133 // <!--End PulumiCodeChooser --> 134 // 135 // ## Import 136 // 137 // Using `pulumi import`, import Configuration Recorder Status using the name of the Configuration Recorder. For example: 138 // 139 // ```sh 140 // $ pulumi import aws:cfg/recorderStatus:RecorderStatus foo example 141 // ``` 142 type RecorderStatus struct { 143 pulumi.CustomResourceState 144 145 // Whether the configuration recorder should be enabled or disabled. 146 IsEnabled pulumi.BoolOutput `pulumi:"isEnabled"` 147 // The name of the recorder 148 Name pulumi.StringOutput `pulumi:"name"` 149 } 150 151 // NewRecorderStatus registers a new resource with the given unique name, arguments, and options. 152 func NewRecorderStatus(ctx *pulumi.Context, 153 name string, args *RecorderStatusArgs, opts ...pulumi.ResourceOption) (*RecorderStatus, error) { 154 if args == nil { 155 return nil, errors.New("missing one or more required arguments") 156 } 157 158 if args.IsEnabled == nil { 159 return nil, errors.New("invalid value for required argument 'IsEnabled'") 160 } 161 opts = internal.PkgResourceDefaultOpts(opts) 162 var resource RecorderStatus 163 err := ctx.RegisterResource("aws:cfg/recorderStatus:RecorderStatus", name, args, &resource, opts...) 164 if err != nil { 165 return nil, err 166 } 167 return &resource, nil 168 } 169 170 // GetRecorderStatus gets an existing RecorderStatus resource's state with the given name, ID, and optional 171 // state properties that are used to uniquely qualify the lookup (nil if not required). 172 func GetRecorderStatus(ctx *pulumi.Context, 173 name string, id pulumi.IDInput, state *RecorderStatusState, opts ...pulumi.ResourceOption) (*RecorderStatus, error) { 174 var resource RecorderStatus 175 err := ctx.ReadResource("aws:cfg/recorderStatus:RecorderStatus", name, id, state, &resource, opts...) 176 if err != nil { 177 return nil, err 178 } 179 return &resource, nil 180 } 181 182 // Input properties used for looking up and filtering RecorderStatus resources. 183 type recorderStatusState struct { 184 // Whether the configuration recorder should be enabled or disabled. 185 IsEnabled *bool `pulumi:"isEnabled"` 186 // The name of the recorder 187 Name *string `pulumi:"name"` 188 } 189 190 type RecorderStatusState struct { 191 // Whether the configuration recorder should be enabled or disabled. 192 IsEnabled pulumi.BoolPtrInput 193 // The name of the recorder 194 Name pulumi.StringPtrInput 195 } 196 197 func (RecorderStatusState) ElementType() reflect.Type { 198 return reflect.TypeOf((*recorderStatusState)(nil)).Elem() 199 } 200 201 type recorderStatusArgs struct { 202 // Whether the configuration recorder should be enabled or disabled. 203 IsEnabled bool `pulumi:"isEnabled"` 204 // The name of the recorder 205 Name *string `pulumi:"name"` 206 } 207 208 // The set of arguments for constructing a RecorderStatus resource. 209 type RecorderStatusArgs struct { 210 // Whether the configuration recorder should be enabled or disabled. 211 IsEnabled pulumi.BoolInput 212 // The name of the recorder 213 Name pulumi.StringPtrInput 214 } 215 216 func (RecorderStatusArgs) ElementType() reflect.Type { 217 return reflect.TypeOf((*recorderStatusArgs)(nil)).Elem() 218 } 219 220 type RecorderStatusInput interface { 221 pulumi.Input 222 223 ToRecorderStatusOutput() RecorderStatusOutput 224 ToRecorderStatusOutputWithContext(ctx context.Context) RecorderStatusOutput 225 } 226 227 func (*RecorderStatus) ElementType() reflect.Type { 228 return reflect.TypeOf((**RecorderStatus)(nil)).Elem() 229 } 230 231 func (i *RecorderStatus) ToRecorderStatusOutput() RecorderStatusOutput { 232 return i.ToRecorderStatusOutputWithContext(context.Background()) 233 } 234 235 func (i *RecorderStatus) ToRecorderStatusOutputWithContext(ctx context.Context) RecorderStatusOutput { 236 return pulumi.ToOutputWithContext(ctx, i).(RecorderStatusOutput) 237 } 238 239 // RecorderStatusArrayInput is an input type that accepts RecorderStatusArray and RecorderStatusArrayOutput values. 240 // You can construct a concrete instance of `RecorderStatusArrayInput` via: 241 // 242 // RecorderStatusArray{ RecorderStatusArgs{...} } 243 type RecorderStatusArrayInput interface { 244 pulumi.Input 245 246 ToRecorderStatusArrayOutput() RecorderStatusArrayOutput 247 ToRecorderStatusArrayOutputWithContext(context.Context) RecorderStatusArrayOutput 248 } 249 250 type RecorderStatusArray []RecorderStatusInput 251 252 func (RecorderStatusArray) ElementType() reflect.Type { 253 return reflect.TypeOf((*[]*RecorderStatus)(nil)).Elem() 254 } 255 256 func (i RecorderStatusArray) ToRecorderStatusArrayOutput() RecorderStatusArrayOutput { 257 return i.ToRecorderStatusArrayOutputWithContext(context.Background()) 258 } 259 260 func (i RecorderStatusArray) ToRecorderStatusArrayOutputWithContext(ctx context.Context) RecorderStatusArrayOutput { 261 return pulumi.ToOutputWithContext(ctx, i).(RecorderStatusArrayOutput) 262 } 263 264 // RecorderStatusMapInput is an input type that accepts RecorderStatusMap and RecorderStatusMapOutput values. 265 // You can construct a concrete instance of `RecorderStatusMapInput` via: 266 // 267 // RecorderStatusMap{ "key": RecorderStatusArgs{...} } 268 type RecorderStatusMapInput interface { 269 pulumi.Input 270 271 ToRecorderStatusMapOutput() RecorderStatusMapOutput 272 ToRecorderStatusMapOutputWithContext(context.Context) RecorderStatusMapOutput 273 } 274 275 type RecorderStatusMap map[string]RecorderStatusInput 276 277 func (RecorderStatusMap) ElementType() reflect.Type { 278 return reflect.TypeOf((*map[string]*RecorderStatus)(nil)).Elem() 279 } 280 281 func (i RecorderStatusMap) ToRecorderStatusMapOutput() RecorderStatusMapOutput { 282 return i.ToRecorderStatusMapOutputWithContext(context.Background()) 283 } 284 285 func (i RecorderStatusMap) ToRecorderStatusMapOutputWithContext(ctx context.Context) RecorderStatusMapOutput { 286 return pulumi.ToOutputWithContext(ctx, i).(RecorderStatusMapOutput) 287 } 288 289 type RecorderStatusOutput struct{ *pulumi.OutputState } 290 291 func (RecorderStatusOutput) ElementType() reflect.Type { 292 return reflect.TypeOf((**RecorderStatus)(nil)).Elem() 293 } 294 295 func (o RecorderStatusOutput) ToRecorderStatusOutput() RecorderStatusOutput { 296 return o 297 } 298 299 func (o RecorderStatusOutput) ToRecorderStatusOutputWithContext(ctx context.Context) RecorderStatusOutput { 300 return o 301 } 302 303 // Whether the configuration recorder should be enabled or disabled. 304 func (o RecorderStatusOutput) IsEnabled() pulumi.BoolOutput { 305 return o.ApplyT(func(v *RecorderStatus) pulumi.BoolOutput { return v.IsEnabled }).(pulumi.BoolOutput) 306 } 307 308 // The name of the recorder 309 func (o RecorderStatusOutput) Name() pulumi.StringOutput { 310 return o.ApplyT(func(v *RecorderStatus) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput) 311 } 312 313 type RecorderStatusArrayOutput struct{ *pulumi.OutputState } 314 315 func (RecorderStatusArrayOutput) ElementType() reflect.Type { 316 return reflect.TypeOf((*[]*RecorderStatus)(nil)).Elem() 317 } 318 319 func (o RecorderStatusArrayOutput) ToRecorderStatusArrayOutput() RecorderStatusArrayOutput { 320 return o 321 } 322 323 func (o RecorderStatusArrayOutput) ToRecorderStatusArrayOutputWithContext(ctx context.Context) RecorderStatusArrayOutput { 324 return o 325 } 326 327 func (o RecorderStatusArrayOutput) Index(i pulumi.IntInput) RecorderStatusOutput { 328 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *RecorderStatus { 329 return vs[0].([]*RecorderStatus)[vs[1].(int)] 330 }).(RecorderStatusOutput) 331 } 332 333 type RecorderStatusMapOutput struct{ *pulumi.OutputState } 334 335 func (RecorderStatusMapOutput) ElementType() reflect.Type { 336 return reflect.TypeOf((*map[string]*RecorderStatus)(nil)).Elem() 337 } 338 339 func (o RecorderStatusMapOutput) ToRecorderStatusMapOutput() RecorderStatusMapOutput { 340 return o 341 } 342 343 func (o RecorderStatusMapOutput) ToRecorderStatusMapOutputWithContext(ctx context.Context) RecorderStatusMapOutput { 344 return o 345 } 346 347 func (o RecorderStatusMapOutput) MapIndex(k pulumi.StringInput) RecorderStatusOutput { 348 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *RecorderStatus { 349 return vs[0].(map[string]*RecorderStatus)[vs[1].(string)] 350 }).(RecorderStatusOutput) 351 } 352 353 func init() { 354 pulumi.RegisterInputType(reflect.TypeOf((*RecorderStatusInput)(nil)).Elem(), &RecorderStatus{}) 355 pulumi.RegisterInputType(reflect.TypeOf((*RecorderStatusArrayInput)(nil)).Elem(), RecorderStatusArray{}) 356 pulumi.RegisterInputType(reflect.TypeOf((*RecorderStatusMapInput)(nil)).Elem(), RecorderStatusMap{}) 357 pulumi.RegisterOutputType(RecorderStatusOutput{}) 358 pulumi.RegisterOutputType(RecorderStatusArrayOutput{}) 359 pulumi.RegisterOutputType(RecorderStatusMapOutput{}) 360 }