Skip to content

Commit 55aa10e

Browse files
committed
Introduced dynatrace_web_app_auto_injection resource
1 parent f7d9265 commit 55aa10e

File tree

14 files changed

+643
-0
lines changed

14 files changed

+643
-0
lines changed

.github/workflows/tests.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,19 @@ jobs:
8686
DT_CLIENT_SECRET: ${{ secrets.DT_CLIENT_SECRET }}
8787
DT_ACCOUNT_ID: ${{ secrets.DT_ACCOUNT_ID }}
8888
run: go test -v ./dynatrace/api/v1/config/reports
89+
- name: TestAccWebAppAutoInjection
90+
if: success() || failure()
91+
env:
92+
GOPROXY: "https://proxy.golang.org"
93+
TF_ACC: true
94+
DYNATRACE_DEBUG: true
95+
DT_NO_REPAIR_INPUT: false
96+
DYNATRACE_ENV_URL: ${{ secrets.DYNATRACE_ENV_URL }}
97+
DYNATRACE_API_TOKEN: ${{ secrets.DYNATRACE_API_TOKEN }}
98+
DT_CLIENT_ID: ${{ secrets.DT_CLIENT_ID }}
99+
DT_CLIENT_SECRET: ${{ secrets.DT_CLIENT_SECRET }}
100+
DT_ACCOUNT_ID: ${{ secrets.DT_ACCOUNT_ID }}
101+
run: go test -v ./dynatrace/api/builtin/rum/web/automaticinjection
89102
- name: TestAccBizEventsCapturingVariants
90103
if: success() || failure()
91104
env:
Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
{
2+
"allowedScopes": [
3+
"APPLICATION"
4+
],
5+
"constraints": [
6+
{
7+
"customMessage": "OneAgent JavaScript Tag with SRI is only available for the Real User Monitoring code source CDN.",
8+
"customValidatorId": "rumAutomaticInjectionSubresourceIntegrityValidator",
9+
"skipAsyncValidation": false,
10+
"type": "CUSTOM_VALIDATOR_REF"
11+
}
12+
],
13+
"description": "Dynatrace OneAgent automatically injects the RUM JavaScript into the HTML head of monitored application pages. Use this page to control and adjust the injection.",
14+
"displayName": "Automatic injection",
15+
"documentation": "",
16+
"dynatrace": "1",
17+
"enums": {
18+
"CodeSnippetType": {
19+
"description": "",
20+
"displayName": "CodeSnippetType",
21+
"documentation": "",
22+
"items": [
23+
{
24+
"displayName": "synchronously",
25+
"value": "SYNCHRONOUSLY"
26+
},
27+
{
28+
"displayName": "deferred",
29+
"value": "DEFERRED"
30+
}
31+
],
32+
"type": "enum"
33+
}
34+
},
35+
"maxObjects": 1,
36+
"multiObject": false,
37+
"properties": {
38+
"cacheControlHeaders": {
39+
"description": "",
40+
"displayName": "Cache control headers",
41+
"documentation": "",
42+
"maxObjects": 1,
43+
"modificationPolicy": "DEFAULT",
44+
"nullable": false,
45+
"type": {
46+
"$ref": "#/types/CacheControlHeaders"
47+
}
48+
},
49+
"monitoringCodeSourceSection": {
50+
"description": "",
51+
"displayName": "Real User Monitoring code source",
52+
"documentation": "",
53+
"maxObjects": 1,
54+
"modificationPolicy": "DEFAULT",
55+
"nullable": false,
56+
"type": {
57+
"$ref": "#/types/MonitoringCodeSource"
58+
}
59+
},
60+
"snippetFormat": {
61+
"description": "",
62+
"displayName": "Snippet format",
63+
"documentation": "*Code Snippet:* OneAgent injects an inline script that initializes Dynatrace and dynamically downloads the monitoring code into your application. Use when you want to inject the monitoring code in deferred mode.\n\n *Inline Code:* OneAgent injects the configuration and the monitoring code inline into your application. Use this injection type when you need to keep the number of web requests at a minimum.\n\n *OneAgent JavaScript Tag:* OneAgent injects a JavaScript tag into your application, containing the configuration and a link to the monitoring code. This is our default injection type, since it's most versatile.\n\nCompare the different [injection formats](https://dt-url.net/vx5g0ptn).",
64+
"maxObjects": 1,
65+
"modificationPolicy": "DEFAULT",
66+
"nullable": false,
67+
"type": {
68+
"$ref": "#/types/SnippetFormat"
69+
}
70+
}
71+
},
72+
"schemaGroups": [
73+
"group:rum-injection"
74+
],
75+
"schemaId": "builtin:rum.web.automatic-injection",
76+
"types": {
77+
"CacheControlHeaders": {
78+
"description": "",
79+
"displayName": "",
80+
"documentation": "",
81+
"properties": {
82+
"cacheControlHeaders": {
83+
"default": true,
84+
"description": "[How to ensure timely configuration updates for automatic injection?](https://dt-url.net/m9039ea)",
85+
"displayName": "Optimize the value of cache control headers for use with Dynatrace Real User Monitoring",
86+
"documentation": "",
87+
"maxObjects": 1,
88+
"modificationPolicy": "DEFAULT",
89+
"nullable": false,
90+
"type": "boolean"
91+
}
92+
},
93+
"summaryPattern": "",
94+
"type": "object",
95+
"version": "0.0.1",
96+
"versionInfo": ""
97+
},
98+
"MonitoringCodeSource": {
99+
"description": "",
100+
"displayName": "",
101+
"documentation": "",
102+
"properties": {
103+
"codeSource": {
104+
"constraints": [
105+
{
106+
"maxLength": 500,
107+
"minLength": 1,
108+
"type": "LENGTH"
109+
}
110+
],
111+
"datasource": {
112+
"filterProperties": [],
113+
"fullContext": false,
114+
"identifier": "codeSourceDataSource",
115+
"resetValue": "NEVER",
116+
"useApiSearch": false,
117+
"validate": true
118+
},
119+
"default": "OneAgent",
120+
"description": "",
121+
"displayName": "Real User Monitoring code source",
122+
"documentation": "",
123+
"maxObjects": 1,
124+
"modificationPolicy": "DEFAULT",
125+
"nullable": false,
126+
"subType": "datasource",
127+
"type": "text"
128+
},
129+
"monitoringCodePath": {
130+
"constraints": [
131+
{
132+
"customMessage": "Path must be relative and a maximum of 255 characters long",
133+
"customValidatorId": "rumAutomaticInjectionMonitoringCodePathValidator",
134+
"skipAsyncValidation": false,
135+
"type": "CUSTOM_VALIDATOR_REF"
136+
},
137+
{
138+
"maxLength": 500,
139+
"minLength": 1,
140+
"type": "LENGTH"
141+
}
142+
],
143+
"description": "Specify the source path for placement of your application's custom JavaScript library file. By default, this path is set to the root directory of your web server. A custom source path may be necessary if your server operates behind a firewall.",
144+
"displayName": "Specify location for JavaScript library file",
145+
"documentation": "",
146+
"maxObjects": 1,
147+
"metadata": {
148+
"placeholder": "For example, /serverpath/"
149+
},
150+
"modificationPolicy": "DEFAULT",
151+
"nullable": true,
152+
"precondition": {
153+
"expectedValue": "OneAgent",
154+
"property": "codeSource",
155+
"type": "EQUALS"
156+
},
157+
"type": "text"
158+
}
159+
},
160+
"summaryPattern": "",
161+
"type": "object",
162+
"version": "0.0.2",
163+
"versionInfo": ""
164+
},
165+
"SnippetFormat": {
166+
"description": "",
167+
"displayName": "",
168+
"documentation": "",
169+
"properties": {
170+
"codeSnippetType": {
171+
"default": "SYNCHRONOUSLY",
172+
"description": "",
173+
"displayName": "Load the monitoring code",
174+
"documentation": "",
175+
"maxObjects": 1,
176+
"modificationPolicy": "DEFAULT",
177+
"nullable": false,
178+
"precondition": {
179+
"expectedValue": "Code Snippet",
180+
"property": "snippetFormat",
181+
"type": "EQUALS"
182+
},
183+
"type": {
184+
"$ref": "#/enums/CodeSnippetType"
185+
}
186+
},
187+
"snippetFormat": {
188+
"constraints": [
189+
{
190+
"maxLength": 500,
191+
"minLength": 1,
192+
"type": "LENGTH"
193+
}
194+
],
195+
"datasource": {
196+
"filterProperties": [],
197+
"fullContext": false,
198+
"identifier": "autoInjectedSnippetFormatDatasource",
199+
"resetValue": "NEVER",
200+
"useApiSearch": false,
201+
"validate": true
202+
},
203+
"default": "OneAgent JavaScript Tag",
204+
"description": "",
205+
"displayName": "Snippet format",
206+
"documentation": "",
207+
"maxObjects": 1,
208+
"modificationPolicy": "DEFAULT",
209+
"nullable": false,
210+
"subType": "datasource",
211+
"type": "text"
212+
}
213+
},
214+
"summaryPattern": "",
215+
"type": "object",
216+
"version": "0.0.1",
217+
"versionInfo": ""
218+
}
219+
},
220+
"version": "1"
221+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Dynatrace LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package automaticinjection
19+
20+
import (
21+
automaticinjection "github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/api/builtin/rum/web/automaticinjection/settings"
22+
"github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/settings"
23+
"github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/settings/services/settings20"
24+
)
25+
26+
const SchemaVersion = "1"
27+
const SchemaID = "builtin:rum.web.automatic-injection"
28+
29+
func Service(credentials *settings.Credentials) settings.CRUDService[*automaticinjection.Settings] {
30+
return settings20.Service[*automaticinjection.Settings](credentials, SchemaID, SchemaVersion)
31+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Dynatrace LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package automaticinjection_test
19+
20+
import (
21+
"testing"
22+
)
23+
24+
func TestAccWebAppAutoInjection(t *testing.T) {
25+
// Temporarily disabled - not available on test tenant (enable with v309)
26+
// api.TestAcc(t)
27+
t.Skip()
28+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Dynatrace LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package automaticinjection
19+
20+
import (
21+
"github.com/dynatrace-oss/terraform-provider-dynatrace/terraform/hcl"
22+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
23+
)
24+
25+
type CacheControlHeaders struct {
26+
CacheControlHeaders bool `json:"cacheControlHeaders"` // [How to ensure timely configuration updates for automatic injection?](https://dt-url.net/m9039ea)
27+
}
28+
29+
func (me *CacheControlHeaders) Schema() map[string]*schema.Schema {
30+
return map[string]*schema.Schema{
31+
"cache_control_headers": {
32+
Type: schema.TypeBool,
33+
Description: "[How to ensure timely configuration updates for automatic injection?](https://dt-url.net/m9039ea)",
34+
Required: true,
35+
},
36+
}
37+
}
38+
39+
func (me *CacheControlHeaders) MarshalHCL(properties hcl.Properties) error {
40+
return properties.EncodeAll(map[string]any{
41+
"cache_control_headers": me.CacheControlHeaders,
42+
})
43+
}
44+
45+
func (me *CacheControlHeaders) UnmarshalHCL(decoder hcl.Decoder) error {
46+
return decoder.DecodeAll(map[string]any{
47+
"cache_control_headers": &me.CacheControlHeaders,
48+
})
49+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Dynatrace LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package automaticinjection
19+
20+
type CodeSnippetType string
21+
22+
var CodeSnippetTypes = struct {
23+
Deferred CodeSnippetType
24+
Synchronously CodeSnippetType
25+
}{
26+
"DEFERRED",
27+
"SYNCHRONOUSLY",
28+
}

0 commit comments

Comments
 (0)