github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/directoryservice/logService.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 directoryservice 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 a Log subscription for AWS Directory Service that pushes logs to cloudwatch. 16 // 17 // ## Example Usage 18 // 19 // <!--Start PulumiCodeChooser --> 20 // ```go 21 // package main 22 // 23 // import ( 24 // 25 // "fmt" 26 // 27 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudwatch" 28 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/directoryservice" 29 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam" 30 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 31 // 32 // ) 33 // 34 // func main() { 35 // pulumi.Run(func(ctx *pulumi.Context) error { 36 // example, err := cloudwatch.NewLogGroup(ctx, "example", &cloudwatch.LogGroupArgs{ 37 // Name: pulumi.String(fmt.Sprintf("/aws/directoryservice/%v", exampleAwsDirectoryServiceDirectory.Id)), 38 // RetentionInDays: pulumi.Int(14), 39 // }) 40 // if err != nil { 41 // return err 42 // } 43 // ad_log_policy := iam.GetPolicyDocumentOutput(ctx, iam.GetPolicyDocumentOutputArgs{ 44 // Statements: iam.GetPolicyDocumentStatementArray{ 45 // &iam.GetPolicyDocumentStatementArgs{ 46 // Actions: pulumi.StringArray{ 47 // pulumi.String("logs:CreateLogStream"), 48 // pulumi.String("logs:PutLogEvents"), 49 // }, 50 // Principals: iam.GetPolicyDocumentStatementPrincipalArray{ 51 // &iam.GetPolicyDocumentStatementPrincipalArgs{ 52 // Identifiers: pulumi.StringArray{ 53 // pulumi.String("ds.amazonaws.com"), 54 // }, 55 // Type: pulumi.String("Service"), 56 // }, 57 // }, 58 // Resources: pulumi.StringArray{ 59 // example.Arn.ApplyT(func(arn string) (string, error) { 60 // return fmt.Sprintf("%v:*", arn), nil 61 // }).(pulumi.StringOutput), 62 // }, 63 // Effect: pulumi.String("Allow"), 64 // }, 65 // }, 66 // }, nil) 67 // _, err = cloudwatch.NewLogResourcePolicy(ctx, "ad-log-policy", &cloudwatch.LogResourcePolicyArgs{ 68 // PolicyDocument: ad_log_policy.ApplyT(func(ad_log_policy iam.GetPolicyDocumentResult) (*string, error) { 69 // return &ad_log_policy.Json, nil 70 // }).(pulumi.StringPtrOutput), 71 // PolicyName: pulumi.String("ad-log-policy"), 72 // }) 73 // if err != nil { 74 // return err 75 // } 76 // _, err = directoryservice.NewLogService(ctx, "example", &directoryservice.LogServiceArgs{ 77 // DirectoryId: pulumi.Any(exampleAwsDirectoryServiceDirectory.Id), 78 // LogGroupName: example.Name, 79 // }) 80 // if err != nil { 81 // return err 82 // } 83 // return nil 84 // }) 85 // } 86 // 87 // ``` 88 // <!--End PulumiCodeChooser --> 89 // 90 // ## Import 91 // 92 // Using `pulumi import`, import Directory Service Log Subscriptions using the directory id. For example: 93 // 94 // ```sh 95 // $ pulumi import aws:directoryservice/logService:LogService msad d-1234567890 96 // ``` 97 type LogService struct { 98 pulumi.CustomResourceState 99 100 // ID of directory. 101 DirectoryId pulumi.StringOutput `pulumi:"directoryId"` 102 // Name of the cloudwatch log group to which the logs should be published. The log group should be already created and the directory service principal should be provided with required permission to create stream and publish logs. Changing this value would delete the current subscription and create a new one. A directory can only have one log subscription at a time. 103 LogGroupName pulumi.StringOutput `pulumi:"logGroupName"` 104 } 105 106 // NewLogService registers a new resource with the given unique name, arguments, and options. 107 func NewLogService(ctx *pulumi.Context, 108 name string, args *LogServiceArgs, opts ...pulumi.ResourceOption) (*LogService, error) { 109 if args == nil { 110 return nil, errors.New("missing one or more required arguments") 111 } 112 113 if args.DirectoryId == nil { 114 return nil, errors.New("invalid value for required argument 'DirectoryId'") 115 } 116 if args.LogGroupName == nil { 117 return nil, errors.New("invalid value for required argument 'LogGroupName'") 118 } 119 opts = internal.PkgResourceDefaultOpts(opts) 120 var resource LogService 121 err := ctx.RegisterResource("aws:directoryservice/logService:LogService", name, args, &resource, opts...) 122 if err != nil { 123 return nil, err 124 } 125 return &resource, nil 126 } 127 128 // GetLogService gets an existing LogService resource's state with the given name, ID, and optional 129 // state properties that are used to uniquely qualify the lookup (nil if not required). 130 func GetLogService(ctx *pulumi.Context, 131 name string, id pulumi.IDInput, state *LogServiceState, opts ...pulumi.ResourceOption) (*LogService, error) { 132 var resource LogService 133 err := ctx.ReadResource("aws:directoryservice/logService:LogService", name, id, state, &resource, opts...) 134 if err != nil { 135 return nil, err 136 } 137 return &resource, nil 138 } 139 140 // Input properties used for looking up and filtering LogService resources. 141 type logServiceState struct { 142 // ID of directory. 143 DirectoryId *string `pulumi:"directoryId"` 144 // Name of the cloudwatch log group to which the logs should be published. The log group should be already created and the directory service principal should be provided with required permission to create stream and publish logs. Changing this value would delete the current subscription and create a new one. A directory can only have one log subscription at a time. 145 LogGroupName *string `pulumi:"logGroupName"` 146 } 147 148 type LogServiceState struct { 149 // ID of directory. 150 DirectoryId pulumi.StringPtrInput 151 // Name of the cloudwatch log group to which the logs should be published. The log group should be already created and the directory service principal should be provided with required permission to create stream and publish logs. Changing this value would delete the current subscription and create a new one. A directory can only have one log subscription at a time. 152 LogGroupName pulumi.StringPtrInput 153 } 154 155 func (LogServiceState) ElementType() reflect.Type { 156 return reflect.TypeOf((*logServiceState)(nil)).Elem() 157 } 158 159 type logServiceArgs struct { 160 // ID of directory. 161 DirectoryId string `pulumi:"directoryId"` 162 // Name of the cloudwatch log group to which the logs should be published. The log group should be already created and the directory service principal should be provided with required permission to create stream and publish logs. Changing this value would delete the current subscription and create a new one. A directory can only have one log subscription at a time. 163 LogGroupName string `pulumi:"logGroupName"` 164 } 165 166 // The set of arguments for constructing a LogService resource. 167 type LogServiceArgs struct { 168 // ID of directory. 169 DirectoryId pulumi.StringInput 170 // Name of the cloudwatch log group to which the logs should be published. The log group should be already created and the directory service principal should be provided with required permission to create stream and publish logs. Changing this value would delete the current subscription and create a new one. A directory can only have one log subscription at a time. 171 LogGroupName pulumi.StringInput 172 } 173 174 func (LogServiceArgs) ElementType() reflect.Type { 175 return reflect.TypeOf((*logServiceArgs)(nil)).Elem() 176 } 177 178 type LogServiceInput interface { 179 pulumi.Input 180 181 ToLogServiceOutput() LogServiceOutput 182 ToLogServiceOutputWithContext(ctx context.Context) LogServiceOutput 183 } 184 185 func (*LogService) ElementType() reflect.Type { 186 return reflect.TypeOf((**LogService)(nil)).Elem() 187 } 188 189 func (i *LogService) ToLogServiceOutput() LogServiceOutput { 190 return i.ToLogServiceOutputWithContext(context.Background()) 191 } 192 193 func (i *LogService) ToLogServiceOutputWithContext(ctx context.Context) LogServiceOutput { 194 return pulumi.ToOutputWithContext(ctx, i).(LogServiceOutput) 195 } 196 197 // LogServiceArrayInput is an input type that accepts LogServiceArray and LogServiceArrayOutput values. 198 // You can construct a concrete instance of `LogServiceArrayInput` via: 199 // 200 // LogServiceArray{ LogServiceArgs{...} } 201 type LogServiceArrayInput interface { 202 pulumi.Input 203 204 ToLogServiceArrayOutput() LogServiceArrayOutput 205 ToLogServiceArrayOutputWithContext(context.Context) LogServiceArrayOutput 206 } 207 208 type LogServiceArray []LogServiceInput 209 210 func (LogServiceArray) ElementType() reflect.Type { 211 return reflect.TypeOf((*[]*LogService)(nil)).Elem() 212 } 213 214 func (i LogServiceArray) ToLogServiceArrayOutput() LogServiceArrayOutput { 215 return i.ToLogServiceArrayOutputWithContext(context.Background()) 216 } 217 218 func (i LogServiceArray) ToLogServiceArrayOutputWithContext(ctx context.Context) LogServiceArrayOutput { 219 return pulumi.ToOutputWithContext(ctx, i).(LogServiceArrayOutput) 220 } 221 222 // LogServiceMapInput is an input type that accepts LogServiceMap and LogServiceMapOutput values. 223 // You can construct a concrete instance of `LogServiceMapInput` via: 224 // 225 // LogServiceMap{ "key": LogServiceArgs{...} } 226 type LogServiceMapInput interface { 227 pulumi.Input 228 229 ToLogServiceMapOutput() LogServiceMapOutput 230 ToLogServiceMapOutputWithContext(context.Context) LogServiceMapOutput 231 } 232 233 type LogServiceMap map[string]LogServiceInput 234 235 func (LogServiceMap) ElementType() reflect.Type { 236 return reflect.TypeOf((*map[string]*LogService)(nil)).Elem() 237 } 238 239 func (i LogServiceMap) ToLogServiceMapOutput() LogServiceMapOutput { 240 return i.ToLogServiceMapOutputWithContext(context.Background()) 241 } 242 243 func (i LogServiceMap) ToLogServiceMapOutputWithContext(ctx context.Context) LogServiceMapOutput { 244 return pulumi.ToOutputWithContext(ctx, i).(LogServiceMapOutput) 245 } 246 247 type LogServiceOutput struct{ *pulumi.OutputState } 248 249 func (LogServiceOutput) ElementType() reflect.Type { 250 return reflect.TypeOf((**LogService)(nil)).Elem() 251 } 252 253 func (o LogServiceOutput) ToLogServiceOutput() LogServiceOutput { 254 return o 255 } 256 257 func (o LogServiceOutput) ToLogServiceOutputWithContext(ctx context.Context) LogServiceOutput { 258 return o 259 } 260 261 // ID of directory. 262 func (o LogServiceOutput) DirectoryId() pulumi.StringOutput { 263 return o.ApplyT(func(v *LogService) pulumi.StringOutput { return v.DirectoryId }).(pulumi.StringOutput) 264 } 265 266 // Name of the cloudwatch log group to which the logs should be published. The log group should be already created and the directory service principal should be provided with required permission to create stream and publish logs. Changing this value would delete the current subscription and create a new one. A directory can only have one log subscription at a time. 267 func (o LogServiceOutput) LogGroupName() pulumi.StringOutput { 268 return o.ApplyT(func(v *LogService) pulumi.StringOutput { return v.LogGroupName }).(pulumi.StringOutput) 269 } 270 271 type LogServiceArrayOutput struct{ *pulumi.OutputState } 272 273 func (LogServiceArrayOutput) ElementType() reflect.Type { 274 return reflect.TypeOf((*[]*LogService)(nil)).Elem() 275 } 276 277 func (o LogServiceArrayOutput) ToLogServiceArrayOutput() LogServiceArrayOutput { 278 return o 279 } 280 281 func (o LogServiceArrayOutput) ToLogServiceArrayOutputWithContext(ctx context.Context) LogServiceArrayOutput { 282 return o 283 } 284 285 func (o LogServiceArrayOutput) Index(i pulumi.IntInput) LogServiceOutput { 286 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *LogService { 287 return vs[0].([]*LogService)[vs[1].(int)] 288 }).(LogServiceOutput) 289 } 290 291 type LogServiceMapOutput struct{ *pulumi.OutputState } 292 293 func (LogServiceMapOutput) ElementType() reflect.Type { 294 return reflect.TypeOf((*map[string]*LogService)(nil)).Elem() 295 } 296 297 func (o LogServiceMapOutput) ToLogServiceMapOutput() LogServiceMapOutput { 298 return o 299 } 300 301 func (o LogServiceMapOutput) ToLogServiceMapOutputWithContext(ctx context.Context) LogServiceMapOutput { 302 return o 303 } 304 305 func (o LogServiceMapOutput) MapIndex(k pulumi.StringInput) LogServiceOutput { 306 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *LogService { 307 return vs[0].(map[string]*LogService)[vs[1].(string)] 308 }).(LogServiceOutput) 309 } 310 311 func init() { 312 pulumi.RegisterInputType(reflect.TypeOf((*LogServiceInput)(nil)).Elem(), &LogService{}) 313 pulumi.RegisterInputType(reflect.TypeOf((*LogServiceArrayInput)(nil)).Elem(), LogServiceArray{}) 314 pulumi.RegisterInputType(reflect.TypeOf((*LogServiceMapInput)(nil)).Elem(), LogServiceMap{}) 315 pulumi.RegisterOutputType(LogServiceOutput{}) 316 pulumi.RegisterOutputType(LogServiceArrayOutput{}) 317 pulumi.RegisterOutputType(LogServiceMapOutput{}) 318 }