MCPcopy Create free account
hub / github.com/OverloadBlitz/cloudcent-cli / DecodeTable

Function DecodeTable

internal/pulumi/resources/aws/dynamodb.go:130–208  ·  view source on GitHub ↗

DecodeTable splits a DynamoDB Table into multiple pricing queries based on billingMode, tableClass, and optional features (PITR, streams, replicas, etc.).

(record resources.ResourceRecord, region, inputsJSON string)

Source from the content-addressed store, hash-verified

128// DecodeTable splits a DynamoDB Table into multiple pricing queries based on
129// billingMode, tableClass, and optional features (PITR, streams, replicas, etc.).
130func DecodeTable(record resources.ResourceRecord, region, inputsJSON string) []resources.DecodedResource {
131 isIA := tableClass(record) == "STANDARD_IA"
132 isPAY := billingMode(record) == "PAY_PER_REQUEST"
133
134 props := map[string]string{
135 "type": record.Type,
136 "billingMode": billingMode(record),
137 "tableClass": tableClass(record),
138 }
139 if v := ExtractInput(record.Inputs, "name"); v != "" {
140 props["name"] = v
141 }
142 if !isPAY {
143 if v := ExtractInput(record.Inputs, "readCapacity"); v != "" {
144 props["readCapacity"] = v
145 }
146 if v := ExtractInput(record.Inputs, "writeCapacity"); v != "" {
147 props["writeCapacity"] = v
148 }
149 }
150
151 var results []resources.DecodedResource
152
153 // 1. Read + Write capacity (always).
154 results = append(results, throughputQueries(record, region, inputsJSON, isPAY, isIA, props)...)
155
156 // 2. Storage (always).
157 storageVolumeType := "Amazon DynamoDB - Indexed DataStore"
158 if isIA {
159 storageVolumeType = "Amazon DynamoDB - Indexed DataStore - IA"
160 }
161 results = append(results, ddbEntry(record, region, inputsJSON, "Storage", "Database Storage",
162 map[string]string{"volumeType": storageVolumeType}, props))
163
164 // 3. Point-In-Time Recovery backup storage.
165 if strings.EqualFold(ExtractInput(record.Inputs, "pointInTimeRecovery.enabled"), "true") {
166 results = append(results, ddbEntry(record, region, inputsJSON, "PITR Backup", "Database Storage",
167 map[string]string{"volumeType": "Amazon DynamoDB - Point-In-Time-Restore (PITR) Backup Storage"}, props))
168 }
169
170 // 4. DynamoDB Streams read requests.
171 if strings.EqualFold(ExtractInput(record.Inputs, "streamEnabled"), "true") {
172 results = append(results, ddbEntry(record, region, inputsJSON, "Stream Reads", "API Request",
173 map[string]string{"group": "DDB-StreamsReadRequests", "usagetype": "Streams-Requests", "operation": "GetRecords"}, props))
174 }
175
176 // 5. Global table replicated writes — one query per replica region.
177 replicaRegions := extractReplicas(record)
178 for _, replicaRegion := range replicaRegions {
179 replicaWriteGroup := "DDB-ReplicatedWriteUnits"
180 if isIA {
181 replicaWriteGroup = "DDB-ReplicatedWriteUnitsIA"
182 }
183 // PAY_PER_REQUEST replicas use DDB-ReplicatedWriteUnits (no IA variant for on-demand).
184 replicaProps := map[string]string{
185 "type": record.Type,
186 "billingMode": billingMode(record),
187 "tableClass": tableClass(record),

Callers

nothing calls this directly

Calls 6

tableClassFunction · 0.85
billingModeFunction · 0.85
ExtractInputFunction · 0.85
throughputQueriesFunction · 0.85
ddbEntryFunction · 0.85
extractReplicasFunction · 0.85

Tested by

no test coverage detected