Skip to content

Commit ea458b8

Browse files
committed
fix: application pool with managed runtime
2 parents 5dfbba5 + deaeaa3 commit ea458b8

File tree

8 files changed

+140
-14
lines changed

8 files changed

+140
-14
lines changed

README.md

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,48 @@
22

33
Terraform Provider using the [Microsoft IIS Administration](https://docs.microsoft.com/en-us/IIS-Administration/) API.
44

5-
## Usage
5+
# Usage
6+
7+
## Setup
8+
69
```hcl
710
provider "iis" {
811
access_key = "your access key"
912
host = "https://localhost:55539"
1013
}
14+
```
15+
16+
## Application pools
1117

18+
```hcl
1219
resource "iis_application_pool" "name" {
1320
name = "AppPool" // Name of the Application Pool
1421
}
22+
```
23+
24+
## Directories
1525

16-
resource "iis_application" "name" {
17-
physical_path = "%systemdrive%\\inetpub\\your_app" // Path on the server to your web app
18-
application_pool = "${iis_application_pool.name.id}"
19-
path = "YourApp" // Path for URL access
20-
website = "${data.iis_website.default.ids[0]}" // id for the website is required
26+
```hcl
27+
resource "iis_file" "name" {
28+
name = "name.of.your.directory"
29+
physical_path = "%systemdrive%\\inetpub\\your_app" // full path to directory
30+
type = "directory" // can also be "file"
31+
parent = "parent_id" // id of the parent folder
2132
}
33+
```
34+
35+
## Websites
2236

23-
data "iis_website" "default" {}
24-
```
37+
```hcl
38+
data "iis_website" "website-domain-com" {
39+
name = "website.domain.com"
40+
physical_path = "%systemdrive%\\inetpub\\your_app" // full path to website folder
41+
application_pool = iis_application_pool.name.id
42+
binding {
43+
protocol = "http"
44+
port = 80
45+
ip_address = "*"
46+
hostname = "website.domain.com"
47+
}
48+
}
49+
```

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module github.com/maxjoehnk/terraform-provider-iis
1+
module github.com/nrgribeiro/terraform-provider-iis
22

33
go 1.15
44

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,6 @@ github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaO
206206
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
207207
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
208208
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
209-
github.com/maxjoehnk/microsoft-iis-administration v0.0.0-20201113134626-dac6f1adc02f h1:WhPrsY6OKWoLXACaMQ4geNH4UU+9FOw5t2zW8xWaSbE=
210-
github.com/maxjoehnk/microsoft-iis-administration v0.0.0-20201113134626-dac6f1adc02f/go.mod h1:RvSyx6SPV+AkzVjVK08vD1VvJ4Hgas/o31yCOesK+hA=
211209
github.com/mitchellh/cli v1.1.1/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI=
212210
github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ=
213211
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=

iis/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func Provider() *schema.Provider {
2424
"iis_application": resourceApplication(),
2525
"iis_authentication": resourceAuthentication(),
2626
"iis_website": resourceWebsite(),
27+
"iis_file": resourceFile(),
2728
},
2829
DataSourcesMap: map[string]*schema.Resource{
2930
"iis_website": dataSourceIisWebsite(),

iis/resource_application_pool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func resourceApplicationPool() *schema.Resource {
2626
ManagedRuntimeKey: {
2727
Type: schema.TypeString,
2828
Optional: true,
29-
Default: "",
29+
Default: "",
3030
},
3131
StatusKey: {
3232
Type: schema.TypeString,

iis/resource_file.go

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
package iis
2+
3+
import (
4+
"context"
5+
"github.com/nrgribeiro/microsoft-iis-administration"
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
7+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
8+
)
9+
10+
const fileNameKey = "name"
11+
const filePhysicalPathKey = "physical_path"
12+
const typeKey = "type"
13+
const parentKey = "parent"
14+
15+
func resourceFile() *schema.Resource {
16+
return &schema.Resource{
17+
CreateContext: resourceFileCreate,
18+
ReadContext: resourceFileRead,
19+
UpdateContext: resourceFileUpdate,
20+
DeleteContext: resourceFileDelete,
21+
22+
Schema: map[string]*schema.Schema{
23+
fileNameKey: {
24+
Type: schema.TypeString,
25+
Required: true,
26+
},
27+
filePhysicalPathKey: {
28+
Type: schema.TypeString,
29+
Required: true,
30+
},
31+
typeKey: {
32+
Type: schema.TypeString,
33+
Required: true,
34+
},
35+
parentKey: {
36+
Type: schema.TypeString,
37+
Required: true,
38+
},
39+
},
40+
}
41+
}
42+
43+
func resourceFileCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
44+
client := m.(*iis.Client)
45+
request := createFileRequest(d)
46+
site, err := client.CreateFile(ctx, request)
47+
if err != nil {
48+
return diag.FromErr(err)
49+
}
50+
d.SetId(site.ID)
51+
return nil
52+
}
53+
54+
func resourceFileRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
55+
client := m.(*iis.Client)
56+
site, err := client.ReadFile(ctx, d.Id())
57+
if err != nil {
58+
d.SetId("")
59+
return diag.FromErr(err)
60+
}
61+
if err = d.Set(nameKey, site.Name); err != nil {
62+
return diag.FromErr(err)
63+
}
64+
if err = d.Set(physicalPathKey, site.PhysicalPath); err != nil {
65+
return diag.FromErr(err)
66+
}
67+
if err = d.Set(typeKey, site.Type); err != nil {
68+
return diag.FromErr(err)
69+
}
70+
return nil
71+
}
72+
73+
func resourceFileUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
74+
return nil
75+
}
76+
77+
func resourceFileDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
78+
client := m.(*iis.Client)
79+
id := d.Id()
80+
err := client.DeleteFile(ctx, id)
81+
if err != nil {
82+
return diag.FromErr(err)
83+
}
84+
return nil
85+
}
86+
87+
func createFileRequest(d *schema.ResourceData) iis.CreateFileRequest {
88+
name := d.Get(nameKey).(string)
89+
physicalPath := d.Get(physicalPathKey).(string)
90+
parentId := d.Get(parentKey).(string)
91+
typeName := d.Get(typeKey).(string)
92+
request := iis.CreateFileRequest{
93+
Name: name,
94+
PhysicalPath: physicalPath,
95+
Parent: iis.FileParent{
96+
Id: parentId,
97+
},
98+
Type: typeName,
99+
}
100+
101+
return request
102+
}

iis/resource_website.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package iis
22

33
import (
44
"context"
5+
"github.com/nrgribeiro/microsoft-iis-administration"
56
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
67
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
7-
"github.com/nrgribeiro/microsoft-iis-administration"
88
)
99

1010
const nameKey = "name"

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package main
22

33
import (
44
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
5-
"github.com/maxjoehnk/terraform-provider-iis/iis"
5+
"github.com/nrgribeiro/terraform-provider-iis/iis"
66
)
77

88
func main() {

0 commit comments

Comments
 (0)