/
table_aws_dax_parameter.go
156 lines (137 loc) · 4.34 KB
/
table_aws_dax_parameter.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
package aws
import (
"context"
"github.com/aws/aws-sdk-go-v2/service/dax"
"github.com/aws/aws-sdk-go-v2/service/dax/types"
daxv1 "github.com/aws/aws-sdk-go/service/dax"
"github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v5/plugin"
"github.com/turbot/steampipe-plugin-sdk/v5/plugin/transform"
)
//// TABLE DEFINITION
func tableAwsDaxParameter(_ context.Context) *plugin.Table {
return &plugin.Table{
Name: "aws_dax_parameter",
Description: "AWS DAX Parameter",
List: &plugin.ListConfig{
ParentHydrate: listDaxParameterGroups,
Hydrate: listDaxParameters,
Tags: map[string]string{"service": "dax", "action": "DescribeParameters"},
IgnoreConfig: &plugin.IgnoreConfig{
ShouldIgnoreErrorFunc: shouldIgnoreErrors([]string{"ParameterGroupNotFoundFault"}),
},
KeyColumns: []*plugin.KeyColumn{
{
Name: "parameter_group_name",
Require: plugin.Optional,
},
},
},
GetMatrixItemFunc: SupportedRegionMatrix(daxv1.EndpointsID),
Columns: awsRegionalColumns([]*plugin.Column{
{
Name: "parameter_name",
Description: "The name of the parameter.",
Type: proto.ColumnType_STRING,
},
{
Name: "parameter_group_name",
Description: "The name of the parameter group.",
Type: proto.ColumnType_STRING,
},
{
Name: "parameter_value",
Description: "The value of the parameter.",
Type: proto.ColumnType_STRING,
},
{
Name: "description",
Description: "Description of the parameter.",
Type: proto.ColumnType_STRING,
},
{
Name: "allowed_values",
Description: "A range of values within which the parameter can be set.",
Type: proto.ColumnType_STRING,
},
{
Name: "change_type",
Description: "The conditions under which changes to this parameter can be applied. Possible values are 'IMMEDIATE', 'REQUIRES_REBOOT'.",
Type: proto.ColumnType_STRING,
},
{
Name: "data_type",
Description: "The data type of the parameter.",
Type: proto.ColumnType_STRING,
},
{
Name: "is_modifiable",
Description: "Whether the customer is allowed to modify the parameter. Possible values are 'TRUE', 'FALSE' 'CONDITIONAL'.",
Type: proto.ColumnType_STRING,
},
{
Name: "parameter_type",
Description: "Determines whether the parameter can be applied to any node or only nodes of a particular type. Possible values are 'DEFAULT', 'NODE_TYPE_SPECIFIC'.",
Type: proto.ColumnType_STRING,
},
{
Name: "source",
Description: "How the parameter is defined. For example, system denotes a system-defined parameter.",
Type: proto.ColumnType_STRING,
},
// Steampipe standard columns
{
Name: "title",
Description: resourceInterfaceDescription("title"),
Type: proto.ColumnType_STRING,
Transform: transform.FromField("ParameterName"),
},
}),
}
}
type Parameter struct {
ParameterGroupName string
types.Parameter
}
//// LIST FUNCTION
func listDaxParameters(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {
parameterGroup := h.Item.(types.ParameterGroup)
// Additonal Filter
equalQuals := d.EqualsQuals
if equalQuals["parameter_group_name"] != nil {
if *parameterGroup.ParameterGroupName != d.EqualsQuals["parameter_group_name"].GetStringValue() {
return nil, nil
}
}
// Create Client
svc, err := DAXClient(ctx, d)
if err != nil {
plugin.Logger(ctx).Error("aws_dax_cluster. listDaxParameters", "connection_error", err)
return nil, err
}
params := &dax.DescribeParametersInput{
ParameterGroupName: parameterGroup.ParameterGroupName,
}
for {
// apply rate limiting
d.WaitForListRateLimit(ctx)
op, err := svc.DescribeParameters(ctx, params)
if err != nil {
plugin.Logger(ctx).Error("aws_dax_cluster. listDaxParameters", "api_error", err)
return nil, err
}
for _, item := range op.Parameters {
d.StreamListItem(ctx, &Parameter{*parameterGroup.ParameterGroupName, item})
// Context can be cancelled due to manual cancellation or the limit has been hit
if d.RowsRemaining(ctx) == 0 {
return nil, nil
}
}
if op.NextToken != nil {
params.NextToken = op.NextToken
} else {
break
}
}
return nil, nil
}