DecodeAllResources decodes collected Pulumi resources using the metadata-driven mapping. It replaces the old per-resource decoder approach — no Go code changes are needed to support new resource types; just update pulumi_resource_map.json in the pipeline and refresh metadata.
(records []resources.ResourceRecord, meta *api.MetadataResponse)
| 39 | // are needed to support new resource types; just update pulumi_resource_map.json |
| 40 | // in the pipeline and refresh metadata. |
| 41 | func DecodeAllResources(records []resources.ResourceRecord, meta *api.MetadataResponse) []resources.DecodedResource { |
| 42 | // Build free-type lookup set from metadata. |
| 43 | freeSet := make(map[string]bool, len(meta.FreeTypes)) |
| 44 | for _, ft := range meta.FreeTypes { |
| 45 | freeSet[ft] = true |
| 46 | } |
| 47 | |
| 48 | var results []resources.DecodedResource |
| 49 | |
| 50 | for _, record := range records { |
| 51 | if skipTypes[record.Type] { |
| 52 | continue |
| 53 | } |
| 54 | |
| 55 | normalizedType := normalizeType(record.Type) |
| 56 | |
| 57 | // Check free types first. |
| 58 | if freeSet[record.Type] || freeSet[normalizedType] { |
| 59 | results = append(results, awsdecode.DecodeFreeResource(record)) |
| 60 | continue |
| 61 | } |
| 62 | |
| 63 | // Look up in pulumi_resources mapping. |
| 64 | mapping, ok := meta.PulumiResources[normalizedType] |
| 65 | if !ok { |
| 66 | // Also try the original type (in case normalizeType changed it). |
| 67 | mapping, ok = meta.PulumiResources[record.Type] |
| 68 | } |
| 69 | if !ok { |
| 70 | // Unknown type — include as no-pricing so it still shows in output. |
| 71 | results = append(results, resources.DecodedResource{ |
| 72 | Name: record.Name, |
| 73 | RawType: record.Type, |
| 74 | NoPricing: true, |
| 75 | Props: awsdecode.InputsToProps(record), |
| 76 | InputsJSON: awsdecode.FormatInputProperties(record.Inputs), |
| 77 | }) |
| 78 | continue |
| 79 | } |
| 80 | |
| 81 | decoded := decodeFromMapping(record, mapping) |
| 82 | results = append(results, decoded...) |
| 83 | } |
| 84 | |
| 85 | return consolidateS3Objects(results) |
| 86 | } |
| 87 | |
| 88 | // s3ObjectTypes are the Pulumi resource types for individual S3 objects. |
| 89 | var s3ObjectTypes = map[string]bool{ |