forked from GoogleCloudPlatform/terraformer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xray.go
43 lines (36 loc) · 1002 Bytes
/
xray.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package aws
import (
"context"
"github.com/GoogleCloudPlatform/terraformer/terraformutils"
"github.com/aws/aws-sdk-go-v2/service/xray"
)
var xrayAllowEmptyValues = []string{"tags."}
type XrayGenerator struct {
AWSService
}
func (g *XrayGenerator) InitResources() error {
config, e := g.generateConfig()
if e != nil {
return e
}
svc := xray.NewFromConfig(config)
p := xray.NewGetSamplingRulesPaginator(svc, &xray.GetSamplingRulesInput{})
for p.HasMorePages() {
page, err := p.NextPage(context.TODO())
if err != nil {
return err
}
for _, samplingRule := range page.SamplingRuleRecords {
// NOTE: Builtin rule with unmodifiable name and 10000 prirority (lowest)
if *samplingRule.SamplingRule.RuleName != "Default" {
g.Resources = append(g.Resources, terraformutils.NewSimpleResource(
*samplingRule.SamplingRule.RuleName,
*samplingRule.SamplingRule.RuleName,
"aws_xray_sampling_rule",
"aws",
xrayAllowEmptyValues))
}
}
}
return nil
}