Skip to content

Commit a528f9b

Browse files
committed
feat: inline microsoft-iis-administration module to configure http logging
1 parent 03bfac6 commit a528f9b

28 files changed

+858
-1197
lines changed

go.mod

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,62 @@
11
module github.com/maxjoehnk/terraform-provider-iis
22

3-
go 1.23.0
3+
go 1.24
44

5-
toolchain go1.24.5
5+
toolchain go1.24.6
66

77
require (
88
github.com/hashicorp/terraform-plugin-log v0.9.0
99
github.com/hashicorp/terraform-plugin-sdk/v2 v2.37.0
10-
github.com/maxjoehnk/microsoft-iis-administration v0.0.0-20201113141114-d361866a46ee
10+
)
11+
12+
require (
13+
github.com/ProtonMail/go-crypto v1.1.6 // indirect
14+
github.com/agext/levenshtein v1.2.2 // indirect
15+
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
16+
github.com/cloudflare/circl v1.6.0 // indirect
17+
github.com/fatih/color v1.16.0 // indirect
18+
github.com/golang/protobuf v1.5.4 // indirect
19+
github.com/google/go-cmp v0.7.0 // indirect
20+
github.com/hashicorp/errwrap v1.0.0 // indirect
21+
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
22+
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
23+
github.com/hashicorp/go-cty v1.5.0 // indirect
24+
github.com/hashicorp/go-hclog v1.6.3 // indirect
25+
github.com/hashicorp/go-multierror v1.1.1 // indirect
26+
github.com/hashicorp/go-plugin v1.6.3 // indirect
27+
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
28+
github.com/hashicorp/go-uuid v1.0.3 // indirect
29+
github.com/hashicorp/go-version v1.7.0 // indirect
30+
github.com/hashicorp/hc-install v0.9.2 // indirect
31+
github.com/hashicorp/hcl/v2 v2.23.0 // indirect
32+
github.com/hashicorp/logutils v1.0.0 // indirect
33+
github.com/hashicorp/terraform-exec v0.23.0 // indirect
34+
github.com/hashicorp/terraform-json v0.25.0 // indirect
35+
github.com/hashicorp/terraform-plugin-go v0.27.0 // indirect
36+
github.com/hashicorp/terraform-registry-address v0.2.5 // indirect
37+
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
38+
github.com/hashicorp/yamux v0.1.1 // indirect
39+
github.com/mattn/go-colorable v0.1.13 // indirect
40+
github.com/mattn/go-isatty v0.0.20 // indirect
41+
github.com/mitchellh/copystructure v1.2.0 // indirect
42+
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
43+
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
44+
github.com/mitchellh/mapstructure v1.5.0 // indirect
45+
github.com/mitchellh/reflectwalk v1.0.2 // indirect
46+
github.com/oklog/run v1.0.0 // indirect
47+
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
48+
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
49+
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
50+
github.com/zclconf/go-cty v1.16.2 // indirect
51+
golang.org/x/crypto v0.38.0 // indirect
52+
golang.org/x/mod v0.24.0 // indirect
53+
golang.org/x/net v0.39.0 // indirect
54+
golang.org/x/sync v0.14.0 // indirect
55+
golang.org/x/sys v0.33.0 // indirect
56+
golang.org/x/text v0.25.0 // indirect
57+
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
58+
google.golang.org/appengine v1.6.8 // indirect
59+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect
60+
google.golang.org/grpc v1.72.1 // indirect
61+
google.golang.org/protobuf v1.36.6 // indirect
1162
)

go.sum

Lines changed: 56 additions & 1167 deletions
Large diffs are not rendered by default.

iis/app_pool.go

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
package iis
2+
3+
import (
4+
"context"
5+
"encoding/json"
6+
"fmt"
7+
)
8+
9+
func (r *ApplicationPool) Marshal() ([]byte, error) {
10+
return json.Marshal(r)
11+
}
12+
13+
type ApplicationPool struct {
14+
Name string `json:"name"`
15+
ID string `json:"id"`
16+
Status string `json:"status"`
17+
AutoStart bool `json:"auto_start"`
18+
PipelineMode string `json:"pipeline_mode"`
19+
ManagedRuntimeVersion string `json:"managed_runtime_version"`
20+
Enable32BitWin64 bool `json:"enable_32bit_win64"`
21+
QueueLength int64 `json:"queue_length"`
22+
CPU CPU `json:"cpu"`
23+
ProcessModel ProcessModel `json:"process_model"`
24+
Identity Identity `json:"identity"`
25+
Recycling Recycling `json:"recycling"`
26+
RapidFailProtection RapidFailProtection `json:"rapid_fail_protection"`
27+
ProcessOrphaning ProcessOrphaning `json:"process_orphaning"`
28+
}
29+
30+
type CPU struct {
31+
Limit int64 `json:"limit"`
32+
//LimitInterval int64 `json:"limit_interval"`
33+
Action string `json:"action"`
34+
ProcessorAffinityEnabled bool `json:"processor_affinity_enabled"`
35+
ProcessorAffinityMask32 string `json:"processor_affinity_mask32"`
36+
ProcessorAffinityMask64 string `json:"processor_affinity_mask64"`
37+
}
38+
39+
type Identity struct {
40+
IdentityType string `json:"identity_type"`
41+
Username string `json:"username"`
42+
LoadUserProfile bool `json:"load_user_profile"`
43+
}
44+
45+
type ProcessModel struct {
46+
//IdleTimeout int64 `json:"idle_timeout"`
47+
MaxProcesses int64 `json:"max_processes"`
48+
PingingEnabled bool `json:"pinging_enabled"`
49+
//PingInterval int64 `json:"ping_interval"`
50+
//PingResponseTime int64 `json:"ping_response_time"`
51+
//ShutdownTimeLimit int64 `json:"shutdown_time_limit"`
52+
//StartupTimeLimit int64 `json:"startup_time_limit"`
53+
IdleTimeoutAction string `json:"idle_timeout_action"`
54+
}
55+
56+
type ProcessOrphaning struct {
57+
Enabled bool `json:"enabled"`
58+
OrphanActionExe string `json:"orphan_action_exe"`
59+
OrphanActionParams string `json:"orphan_action_params"`
60+
}
61+
62+
type RapidFailProtection struct {
63+
Enabled bool `json:"enabled"`
64+
LoadBalancerCapabilities string `json:"load_balancer_capabilities"`
65+
//Interval int64 `json:"interval"`
66+
MaxCrashes int64 `json:"max_crashes"`
67+
AutoShutdownExe string `json:"auto_shutdown_exe"`
68+
AutoShutdownParams string `json:"auto_shutdown_params"`
69+
}
70+
71+
type Recycling struct {
72+
DisableOverlappedRecycle bool `json:"disable_overlapped_recycle"`
73+
DisableRecycleOnConfigChange bool `json:"disable_recycle_on_config_change"`
74+
LogEvents LogEvents `json:"log_events"`
75+
PeriodicRestart PeriodicRestart `json:"periodic_restart"`
76+
}
77+
78+
type LogEvents struct {
79+
Time bool `json:"time"`
80+
Requests bool `json:"requests"`
81+
Schedule bool `json:"schedule"`
82+
Memory bool `json:"memory"`
83+
IsapiUnhealthy bool `json:"isapi_unhealthy"`
84+
OnDemand bool `json:"on_demand"`
85+
ConfigChange bool `json:"config_change"`
86+
PrivateMemory bool `json:"private_memory"`
87+
}
88+
89+
type PeriodicRestart struct {
90+
//TimeInterval int64 `json:"time_interval"`
91+
PrivateMemory int64 `json:"private_memory"`
92+
RequestLimit int64 `json:"request_limit"`
93+
VirtualMemory int64 `json:"virtual_memory"`
94+
Schedule []interface{} `json:"schedule"`
95+
}
96+
97+
func (client Client) ReadAppPool(ctx context.Context, id string) (*ApplicationPool, error) {
98+
url := fmt.Sprintf("/api/webserver/application-pools/%s", id)
99+
var appPool ApplicationPool
100+
if err := getJson(ctx, client, url, &appPool); err != nil {
101+
return nil, err
102+
}
103+
return &appPool, nil
104+
}
105+
106+
func (client Client) DeleteAppPool(ctx context.Context, id string) error {
107+
url := fmt.Sprintf("/api/webserver/application-pools/%s", id)
108+
return httpDelete(ctx, client, url)
109+
}

iis/app_pool_create.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package iis
2+
3+
import (
4+
"context"
5+
"encoding/json"
6+
)
7+
8+
func (client Client) CreateAppPool(ctx context.Context, name string) (*ApplicationPool, error) {
9+
reqBody := CreateApplicationPoolRequest{
10+
Name: name,
11+
}
12+
res, err := httpPost(ctx, client, "/api/webserver/application-pools", reqBody)
13+
if err != nil {
14+
return nil, err
15+
}
16+
var pool ApplicationPool
17+
err = json.Unmarshal(res, &pool)
18+
if err != nil {
19+
return nil, err
20+
}
21+
return &pool, nil
22+
}
23+
24+
type CreateApplicationPoolRequest struct {
25+
Name string `json:"name"`
26+
}

iis/app_pool_update.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package iis
2+
3+
import (
4+
"context"
5+
"encoding/json"
6+
"fmt"
7+
)
8+
9+
func (client Client) UpdateAppPool(ctx context.Context, id, name string) (*ApplicationPool, error) {
10+
reqBody := struct {
11+
Name string `json:"name"`
12+
}{name}
13+
url := fmt.Sprintf("/api/webserver/application-pools/%s", id)
14+
res, err := httpPatch(ctx, client, url, reqBody)
15+
if err != nil {
16+
return nil, err
17+
}
18+
var pool ApplicationPool
19+
err = json.Unmarshal(res, &pool)
20+
if err != nil {
21+
return nil, err
22+
}
23+
return &pool, nil
24+
}

iis/application.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package iis
2+
3+
import (
4+
"context"
5+
"encoding/json"
6+
"fmt"
7+
)
8+
9+
func (r *Application) Marshal() ([]byte, error) {
10+
return json.Marshal(r)
11+
}
12+
13+
type ResourceReferences map[string]*ResourceReference
14+
15+
type ResourceReference struct {
16+
Href string `json:"href"`
17+
}
18+
19+
type Application struct {
20+
Location string `json:"location"`
21+
Path string `json:"path"`
22+
ID string `json:"id"`
23+
PhysicalPath string `json:"physical_path"`
24+
EnabledProtocols string `json:"enabled_protocols"`
25+
Website ApplicationReference `json:"website"`
26+
ApplicationPool ApplicationReference `json:"application_pool"`
27+
Links ResourceReferences `json:"_links,omitempty"`
28+
}
29+
30+
type ApplicationReference struct {
31+
Name string `json:"name"`
32+
ID string `json:"id"`
33+
Status string `json:"status"`
34+
}
35+
36+
func (client Client) ReadApplication(ctx context.Context, id string) (*Application, error) {
37+
url := fmt.Sprintf("/api/webserver/webapps/%s", id)
38+
var app Application
39+
if err := getJson(ctx, client, url, &app); err != nil {
40+
return nil, err
41+
}
42+
return &app, nil
43+
}
44+
45+
func (client Client) DeleteApplication(ctx context.Context, id string) error {
46+
url := fmt.Sprintf("/api/webserver/webapps/%s", id)
47+
return httpDelete(ctx, client, url)
48+
}

iis/application_create.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package iis
2+
3+
import (
4+
"context"
5+
"encoding/json"
6+
"fmt"
7+
)
8+
9+
func (client Client) CreateApplication(ctx context.Context, application CreateApplicationRequest) (*Application, error) {
10+
res, err := httpPost(ctx, client, "/api/webserver/webapps", application)
11+
if err != nil {
12+
return nil, err
13+
}
14+
var app Application
15+
err = json.Unmarshal(res, &app)
16+
if err != nil {
17+
return nil, err
18+
}
19+
fmt.Println(app)
20+
return &app, nil
21+
}
22+
23+
type Reference struct {
24+
ID string `json:"id"`
25+
}
26+
27+
type CreateApplicationRequest struct {
28+
Path string `json:"path"`
29+
PhysicalPath string `json:"physical_path"`
30+
Website Reference `json:"website"`
31+
ApplicationPool Reference `json:"application_pool"`
32+
}

iis/authentication_anonymous.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package iis
2+
3+
import (
4+
"context"
5+
"encoding/json"
6+
"fmt"
7+
)
8+
9+
type AnonymousAuthentication struct {
10+
ID string `json:"id"`
11+
Enabled bool `json:"enabled"`
12+
User string `json:"user"`
13+
}
14+
15+
func (anonymous AnonymousAuthentication) ToMap() map[string]interface{} {
16+
anonymousMap := make(map[string]interface{}, 2)
17+
anonymousMap["enabled"] = anonymous.Enabled
18+
anonymousMap["user"] = anonymous.User
19+
20+
return anonymousMap
21+
}
22+
23+
func (client Client) ReadAnonymousAuthenticationFromId(ctx context.Context, id string) (*AnonymousAuthentication, error) {
24+
url := fmt.Sprintf("/api/webserver/authentication/anonymous-authentication/%s", id)
25+
var auth AnonymousAuthentication
26+
err := getJson(ctx, client, url, &auth)
27+
if err != nil {
28+
return nil, err
29+
}
30+
return &auth, nil
31+
}
32+
33+
func (client Client) UpdateAnonymousAuthentication(ctx context.Context, auth *AnonymousAuthentication) (AnonymousAuthentication, error) {
34+
var anonymous AnonymousAuthentication
35+
url := fmt.Sprintf("/api/webserver/authentication/anonymous-authentication/%s", auth.ID)
36+
res, err := httpPatch(ctx, client, url, &auth)
37+
if err != nil {
38+
return anonymous, err
39+
}
40+
err = json.Unmarshal(res, &anonymous)
41+
if err != nil {
42+
return anonymous, err
43+
}
44+
return anonymous, nil
45+
}

iis/authentication_basic.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package iis
2+
3+
import (
4+
"context"
5+
"encoding/json"
6+
"fmt"
7+
)
8+
9+
type BasicAuthentication struct {
10+
ID string `json:"id"`
11+
Enabled bool `json:"enabled"`
12+
DefaultLogonDomain string `json:"default_logon_domain"`
13+
Realm string `json:"realm"`
14+
}
15+
16+
func (basic BasicAuthentication) ToMap() map[string]interface{} {
17+
basicMap := make(map[string]interface{}, 3)
18+
basicMap["enabled"] = basic.Enabled
19+
basicMap["default_domain"] = basic.DefaultLogonDomain
20+
basicMap["realm"] = basic.Realm
21+
22+
return basicMap
23+
}
24+
25+
func (client Client) UpdateBasicAuthentication(ctx context.Context, auth *BasicAuthentication) (BasicAuthentication, error) {
26+
url := fmt.Sprintf("/api/webserver/authentication/basic-authentication/%s", auth.ID)
27+
var basic BasicAuthentication
28+
res, err := httpPatch(ctx, client, url, &auth)
29+
if err != nil {
30+
return basic, err
31+
}
32+
err = json.Unmarshal(res, &basic)
33+
if err != nil {
34+
return basic, err
35+
}
36+
return basic, nil
37+
}

0 commit comments

Comments
 (0)