Skip to content

Commit 62ae7b5

Browse files
authored
Merge pull request #68 from SumoLogic/apoorv-xray-source
terraform support for xray source
2 parents 385115d + f72040d commit 62ae7b5

File tree

3 files changed

+94
-7
lines changed

3 files changed

+94
-7
lines changed

sumologic/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func Provider() terraform.ResourceProvider {
4444
"sumologic_s3_source": resourceSumologicGenericPollingSource(),
4545
"sumologic_s3_audit_source": resourceSumologicGenericPollingSource(),
4646
"sumologic_cloudwatch_source": resourceSumologicGenericPollingSource(),
47+
"sumologic_aws_xray_source": resourceSumologicGenericPollingSource(),
4748
"sumologic_cloudtrail_source": resourceSumologicGenericPollingSource(),
4849
"sumologic_elb_source": resourceSumologicGenericPollingSource(),
4950
"sumologic_cloudfront_source": resourceSumologicGenericPollingSource(),

sumologic/resource_sumologic_generic_polling_source.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ func resourceSumologicGenericPollingSource() *schema.Resource {
1919
}
2020

2121
pollingSource.Schema["content_type"] = &schema.Schema{
22-
Type: schema.TypeString,
23-
Required: true,
24-
ForceNew: true,
25-
ValidateFunc: validation.StringInSlice([]string{"AwsS3Bucket", "AwsElbBucket", "AwsCloudFrontBucket", "AwsCloudTrailBucket", "AwsS3AuditBucket", "AwsCloudWatch"}, false),
22+
Type: schema.TypeString,
23+
Required: true,
24+
ForceNew: true,
25+
ValidateFunc: validation.StringInSlice([]string{"AwsS3Bucket", "AwsElbBucket", "AwsCloudFrontBucket",
26+
"AwsCloudTrailBucket", "AwsS3AuditBucket", "AwsCloudWatch", "AwsXRay"}, false),
2627
}
2728
pollingSource.Schema["scan_interval"] = &schema.Schema{
2829
Type: schema.TypeInt,
@@ -73,9 +74,10 @@ func resourceSumologicGenericPollingSource() *schema.Resource {
7374
Elem: &schema.Resource{
7475
Schema: map[string]*schema.Schema{
7576
"type": {
76-
Type: schema.TypeString,
77-
Required: true,
78-
ValidateFunc: validation.StringInSlice([]string{"S3BucketPathExpression", "CloudWatchPath"}, false),
77+
Type: schema.TypeString,
78+
Required: true,
79+
ValidateFunc: validation.StringInSlice([]string{"S3BucketPathExpression", "CloudWatchPath",
80+
"AwsXRayPath"}, false),
7981
},
8082
"bucket_name": {
8183
Type: schema.TypeString,
@@ -327,6 +329,14 @@ func getPollingPathSettings(d *schema.ResourceData) PollingPath {
327329
pathSettings.LimitToRegions = LimitToRegions
328330
pathSettings.LimitToNamespaces = LimitToNamespaces
329331
pathSettings.TagFilters = getPollingTagFilters(d)
332+
case "AwsXRayPath":
333+
pathSettings.Type = "AwsXRayPath"
334+
rawLimitToRegions := path["limit_to_regions"].([]interface{})
335+
LimitToRegions := make([]string, len(rawLimitToRegions))
336+
for i, v := range rawLimitToRegions {
337+
LimitToRegions[i] = v.(string)
338+
}
339+
pathSettings.LimitToRegions = LimitToRegions
330340
default:
331341
log.Printf("[ERROR] Unknown resourceType in path: %v", pathType)
332342
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
layout: "sumologic"
3+
page_title: "SumoLogic: sumologic_aws_xray_source"
4+
description: |-
5+
Provides a Sumologic AWS XRay source.
6+
---
7+
8+
# sumologic_aws_xray_source
9+
Provides a Sumologic AWS XRay source to collect metrics derived from XRay traces.
10+
11+
__IMPORTANT:__ The AWS credentials are stored in plain-text in the state. This is a potential security issue.
12+
13+
## Example Usage
14+
```hcl
15+
resource "sumologic_aws_xray_source" "terraform_aws_xray_source" {
16+
name = "AWS XRay Metrics"
17+
description = "My description"
18+
category = "aws/terraform_xray"
19+
content_type = "AwsXRay"
20+
scan_interval = 300000
21+
paused = false
22+
collector_id = "${sumologic_collector.collector.id}"
23+
24+
authentication {
25+
type = "AWSRoleBasedAuthentication"
26+
role_arn = "arn:aws:iam::01234567890:role/sumo-role"
27+
}
28+
29+
path {
30+
type = "AwsXRayPath"
31+
limit_to_regions = ["us-west-2"]
32+
}
33+
}
34+
35+
resource "sumologic_collector" "collector" {
36+
name = "my-collector"
37+
description = "Just testing this"
38+
}
39+
```
40+
41+
## Argument reference
42+
43+
In addition to the common properties, the following arguments are supported:
44+
45+
- `content_type` - (Required) The content-type of the collected data. This has to be `AwsXRay` for AWS XRay source.
46+
- `scan_interval` - (Required) Time interval in milliseconds of scans for new data. The minimum value is 1000 milliseconds. Currently this value is not respected, and collection happens at a default interval of 1 minute.
47+
- `paused` - (Required) When set to true, the scanner is paused. To disable, set to false.
48+
- `authentication` - (Required) Authentication details for making `xray:Get*` calls.
49+
+ `type` - (Required) Must be either `S3BucketAuthentication` or `AWSRoleBasedAuthentication`
50+
+ `access_key` - (Required) Your AWS access key if using type `S3BucketAuthentication`
51+
+ `secret_key` - (Required) Your AWS secret key if using type `S3BucketAuthentication`
52+
+ `role_arn` - (Required) Your AWS role ARN if using type `AWSRoleBasedAuthentication`
53+
- `path` - (Required) The location to scan for new data.
54+
+ `type` - (Required) type of polling source. This has to be `AwsXRayPath` for AWS XRay source.
55+
+ `limit_to_regions` - (Optional) List of Amazon regions.
56+
57+
### See also
58+
* [Common Source Properties](https://github.com/terraform-providers/terraform-provider-sumologic/tree/master/website#common-source-properties)
59+
60+
## Attributes Reference
61+
The following attributes are exported:
62+
63+
- `id` - The internal ID of the source.
64+
65+
## Import
66+
AWS XRay sources can be imported using the collector and source IDs (`collector/source`), e.g.:
67+
68+
```hcl
69+
terraform import sumologic_aws_xray_source.test 123/456
70+
```
71+
72+
AWS XRay sources can be imported using the collector name and source name (`collectorName/sourceName`), e.g.:
73+
74+
```hcl
75+
terraform import sumologic_aws_xray_source.test my-test-collector/my-test-source
76+
```

0 commit comments

Comments
 (0)