forked from JamesWoolfenden/pike
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resource.ps1
executable file
·42 lines (36 loc) · 987 Bytes
/
resource.ps1
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
#!/usr/bin/env pwsh
param([Parameter(Mandatory)][string]$resource, $type="resource")
function path() {
if ($Env:OS -eq "Windows_NT")
{
$slash = "\"
} else {
$slash = "/"
}
$path=$args[0]
for ( $i = 1; $i -lt $args.count; $i++ ) {
$path+=$slash+$args[$i]
}
return $path
}
$provider=$resource.Split("_")[0]
$baseMapping=path . "src" "mapping" $provider
$mapping=path $baseMapping $type
write-host "Copying to $baseMapping"
if (test-path($baseMapping)) {
$source= path $mapping "template.json"
$destination = path $mapping "$resource.json"
Copy-Item -path $source -destination $destination
}
else {
write-host "$baseMapping not found"
}
if ($type -eq "data") {
$content="data `"$resource`" `"pike`" {}"
$tffile=path terraform $provider "$type.$resource.tf"
}
else {
$content="resource `"$resource`" `"pike`" {}"
$tffile=path terraform $provider "$resource.tf"
}
new-item $tffile -value $content