GetModuleFiles returns a map of module files to be used with ExtraFiles
()
| 50 | |
| 51 | // GetModuleFiles returns a map of module files to be used with ExtraFiles |
| 52 | func GetModuleFiles() map[string][]byte { |
| 53 | // Create the modules.json that Terraform needs to see the module |
| 54 | modulesJSON := struct { |
| 55 | Modules []struct { |
| 56 | Key string `json:"Key"` |
| 57 | Source string `json:"Source"` |
| 58 | Dir string `json:"Dir"` |
| 59 | } `json:"Modules"` |
| 60 | }{ |
| 61 | Modules: []struct { |
| 62 | Key string `json:"Key"` |
| 63 | Source string `json:"Source"` |
| 64 | Dir string `json:"Dir"` |
| 65 | }{ |
| 66 | { |
| 67 | Key: "", |
| 68 | Source: "", |
| 69 | Dir: ".", |
| 70 | }, |
| 71 | { |
| 72 | Key: "two", |
| 73 | Source: "./modules/two", |
| 74 | Dir: "modules/two", |
| 75 | }, |
| 76 | }, |
| 77 | } |
| 78 | |
| 79 | modulesJSONBytes, err := json.Marshal(modulesJSON) |
| 80 | if err != nil { |
| 81 | panic(err) // This should never happen with static data |
| 82 | } |
| 83 | |
| 84 | return map[string][]byte{ |
| 85 | "modules/two/main.tf": []byte(moduleTwoMainTF), |
| 86 | ".terraform/modules/modules.json": modulesJSONBytes, |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | func TemplateTarData() ([]byte, error) { |
| 91 | mainTF, err := TemplateContent() |