Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Resource: Front Door Firewall Policy #4125

Merged
merged 85 commits into from
Sep 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
73b0c47
WIP: Initial checkin
WodansSon May 14, 2019
7b2be6d
Updates to Frontdoor
WodansSon May 18, 2019
6dcab9c
Merge from Master
WodansSon Jun 28, 2019
1cb59ce
PIP
WodansSon Jun 28, 2019
200f2a8
PIP
WodansSon Jun 29, 2019
8291122
Finalized Schema
WodansSon Jul 10, 2019
7d66366
WIP Current state
WodansSon Jul 10, 2019
0f412eb
WIP adding validation
WodansSon Jul 16, 2019
4440bab
WIP Finished validation code
WodansSon Jul 17, 2019
04adc2f
WIP Expand RoutingRules working
WodansSon Jul 19, 2019
cf9096f
WIP All expand func implemented
WodansSon Jul 23, 2019
00a51cd
WIP: Functional CreateUpdate done
WodansSon Jul 23, 2019
68b84d0
Cast values and start on flatten functions
WodansSon Jul 24, 2019
c40fcc9
WIP: Last fix routing rules
WodansSon Jul 25, 2019
35c4502
WIP: Fully working Frontdoor
WodansSon Jul 26, 2019
7481722
WIP: Wasnt exactly done... fixed destroy
WodansSon Jul 26, 2019
88e5f6a
gofmt code
WodansSon Jul 26, 2019
0a42aa7
Pull Master
WodansSon Jul 26, 2019
156b97b
WIP: Added first test
WodansSon Jul 27, 2019
ca743f9
Fixed casing issue when interacting with portal
WodansSon Jul 29, 2019
c94c75a
Fix bug in fronend endpoint enum
WodansSon Jul 31, 2019
aab4faf
Bug fix for Frontend Endpoint flatten
WodansSon Jul 31, 2019
f871c66
Add data source
WodansSon Aug 1, 2019
0b8f259
Slight update to documentation
WodansSon Aug 1, 2019
e2ebb0a
Added Frontend client code
WodansSon Aug 6, 2019
36fd014
Extending frontend endpoints schema
WodansSon Aug 7, 2019
51bef98
schema and exposed enable and disable for frontend
WodansSon Aug 9, 2019
ea00b84
Enabled custom HTTPS domain setting
WodansSon Aug 10, 2019
7bf9a73
[WIP] Last code changes
WodansSon Aug 12, 2019
161ac42
Tweeking defaults and adding validation rules
WodansSon Aug 14, 2019
e35c193
[WIP] Update test case
WodansSon Aug 14, 2019
011ac40
Updated documentation and exposed cname
WodansSon Aug 14, 2019
df4d523
fixed flatten for Cert Source AzureKeyVault
WodansSon Aug 14, 2019
4372071
Pull Master
WodansSon Aug 16, 2019
5a004ae
Update to latest
WodansSon Aug 16, 2019
e471f1a
Few changes per PR review
WodansSon Aug 16, 2019
cb3ba6c
Fixed lint errors
WodansSon Aug 16, 2019
1e505b4
Missed one client declaration
WodansSon Aug 16, 2019
ac6a9fa
Fix test client
WodansSon Aug 16, 2019
5c9144e
Removed data source fix lint errs
WodansSon Aug 16, 2019
b721403
update CheckDestroy func
WodansSon Aug 16, 2019
1efa686
[WIP] Initial check-in
WodansSon Aug 20, 2019
98b946f
[WIP] Tuning Schema
WodansSon Aug 21, 2019
162dd5b
[WIP] Schema final
WodansSon Aug 21, 2019
822ef9d
Update website/docs/r/front_door.html.markdown
WodansSon Aug 21, 2019
d54b7fc
Update azurerm/resource_arm_front_door.go
WodansSon Aug 21, 2019
262b1f9
Update azurerm/resource_arm_front_door.go
WodansSon Aug 21, 2019
ba08bca
Update test and docs
WodansSon Aug 22, 2019
e251d71
Fixed conflict
WodansSon Aug 22, 2019
f25eed4
Added test case
WodansSon Aug 22, 2019
d21382e
Update test per PR
WodansSon Aug 22, 2019
28383a9
Address PR issues
WodansSon Aug 22, 2019
c592646
Update website/docs/r/front_door.html.markdown
WodansSon Aug 22, 2019
d42e581
Merge branch 'nr_frontdoor' of https://github.com/terraform-providers…
WodansSon Aug 22, 2019
bc20eef
[WIP] Adding CreateUpdate
WodansSon Aug 22, 2019
5f49486
Added link to internal bug tracking casing issue
WodansSon Aug 22, 2019
f39e2d6
Merge branch 'nr_frontdoor' of https://github.com/terraform-providers…
WodansSon Aug 22, 2019
836e7cd
Merge branch 'nr_frontdoor' of https://github.com/terraform-providers…
WodansSon Aug 23, 2019
0f862ca
[WIP] Progress
WodansSon Aug 23, 2019
3ed1561
gofmt
WodansSon Aug 24, 2019
5d0a281
Merge branch 'nr_frontdoor' of https://github.com/terraform-providers…
WodansSon Aug 24, 2019
d75b8a2
[PIP] More progress
WodansSon Aug 30, 2019
0a8a9e9
[WIP] WAF progress for today
WodansSon Sep 6, 2019
9bd74f1
[WIP] Progress
WodansSon Sep 6, 2019
3202c29
Merge master
WodansSon Sep 9, 2019
953998f
[WIP] Clean up from master merge
WodansSon Sep 9, 2019
992cb9b
[WIP] added EOF new line for client
WodansSon Sep 9, 2019
6648b22
[WIP] More progress
WodansSon Sep 10, 2019
50571e9
[WIP] Progress
WodansSon Sep 11, 2019
7b95660
[WIP] Progress
WodansSon Sep 11, 2019
4e57a4e
[WIP] Working prototype create only
WodansSon Sep 11, 2019
6b06026
[WIP] Update for negation_condition
WodansSon Sep 12, 2019
22fb9c5
[WIP] Fully functioning Create
WodansSon Sep 12, 2019
d2b16e4
[WIP] Refactor
WodansSon Sep 13, 2019
fca8221
[WIP] Progress
WodansSon Sep 14, 2019
4a97e5e
[WIP] Fully function WAF resource
WodansSon Sep 17, 2019
ff040bb
Fix lint error add test case
WodansSon Sep 17, 2019
31bc27a
Fix documentation & add to side bar
katbyte Sep 17, 2019
3f7479b
add nil checks
katbyte Sep 17, 2019
a84ecc7
fix requireResourcesToBeImported check
katbyte Sep 17, 2019
3cd0618
Add WAF to front door
WodansSon Sep 17, 2019
3e5fae9
Merge branch 'master' into nr_frontdoor_firewall-policy
WodansSon Sep 17, 2019
17fe759
Gofmt
WodansSon Sep 18, 2019
ff112e3
Merge branch 'nr_frontdoor_firewall-policy' of https://github.com/ter…
WodansSon Sep 18, 2019
21459a1
Removed unneeded imports
WodansSon Sep 18, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions azurerm/internal/services/frontdoor/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
type Client struct {
FrontDoorsClient *frontdoor.FrontDoorsClient
FrontDoorsFrontendClient *frontdoor.FrontendEndpointsClient
FrontDoorsPolicyClient *frontdoor.PoliciesClient
}

func BuildClient(o *common.ClientOptions) *Client {
Expand All @@ -17,8 +18,12 @@ func BuildClient(o *common.ClientOptions) *Client {
frontDoorsFrontendClient := frontdoor.NewFrontendEndpointsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&frontDoorsFrontendClient.Client, o.ResourceManagerAuthorizer)

frontDoorsPolicyClient := frontdoor.NewPoliciesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&frontDoorsPolicyClient.Client, o.ResourceManagerAuthorizer)

return &Client{
FrontDoorsClient: &frontDoorsClient,
FrontDoorsFrontendClient: &frontDoorsFrontendClient,
FrontDoorsPolicyClient: &frontDoorsPolicyClient,
}
}
23 changes: 23 additions & 0 deletions azurerm/internal/services/frontdoor/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func GetFrontDoorBasicRouteConfigurationType(i interface{}) string {
return "ForwardingConfiguration"
}
}

func VerifyRoutingRuleFrontendEndpoints(routingRuleFrontends []interface{}, configFrontendEndpoints []interface{}) error {
for _, routingRuleFrontend := range routingRuleFrontends {
// Get the name of the frontend defined in the routing rule
Expand Down Expand Up @@ -178,3 +179,25 @@ func VerifyCustomHttpsConfiguration(configFrontendEndpoints []interface{}) error

return nil
}

func FlattenTransformSlice(input *[]frontdoor.TransformType) []interface{} {
result := make([]interface{}, 0)

if input != nil {
for _, item := range *input {
result = append(result, string(item))
}
}
return result
}

func FlattenFrontendEndpointLinkSlice(input *[]frontdoor.FrontendEndpointLink) []interface{} {
result := make([]interface{}, 0)

if input != nil {
for _, item := range *input {
result = append(result, *item.ID)
}
}
return result
}
8 changes: 8 additions & 0 deletions azurerm/internal/services/frontdoor/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ func ValidateBackendPoolRoutingRuleName(i interface{}, k string) (_ []string, er
return nil, errors
}

func ValidateCustomBlockResponseBody(i interface{}, k string) (_ []string, errors []error) {
if m, regexErrs := validate.RegExHelper(i, k, `^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$`); !m {
errors = append(regexErrs, fmt.Errorf(`%q contains invalid characters, %q must contain only alphanumeric and equals sign characters.`, k, k))
}

return nil, errors
}

func ValidateFrontdoorSettings(d *schema.ResourceDiff) error {
routingRules := d.Get("routing_rule").([]interface{})
configFrontendEndpoints := d.Get("frontend_endpoint").([]interface{})
Expand Down
1 change: 1 addition & 0 deletions azurerm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ func Provider() terraform.ResourceProvider {
"azurerm_firewall_network_rule_collection": resourceArmFirewallNetworkRuleCollection(),
"azurerm_firewall": resourceArmFirewall(),
"azurerm_frontdoor": resourceArmFrontDoor(),
"azurerm_frontdoor_firewall_policy": resourceArmFrontDoorFirewallPolicy(),
"azurerm_function_app": resourceArmFunctionApp(),
"azurerm_hdinsight_hadoop_cluster": resourceArmHDInsightHadoopCluster(),
"azurerm_hdinsight_hbase_cluster": resourceArmHDInsightHBaseCluster(),
Expand Down
21 changes: 16 additions & 5 deletions azurerm/resource_arm_front_door.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ func resourceArmFrontDoor() *schema.Resource {
Type: schema.TypeBool,
Required: true,
},
"web_application_firewall_policy_link_id": {
Type: schema.TypeString,
Optional: true,
},
"custom_https_configuration": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -786,6 +790,7 @@ func expandArmFrontDoorFrontendEndpoint(input []interface{}, frontDoorPath strin
isSessionAffinityEnabled := frontendEndpoint["session_affinity_enabled"].(bool)
sessionAffinityTtlSeconds := int32(frontendEndpoint["session_affinity_ttl_seconds"].(int))
customHttpsConfiguration := frontendEndpoint["custom_https_configuration"].([]interface{})
waf := frontendEndpoint["web_application_firewall_policy_link_id"].(string)
name := frontendEndpoint["name"].(string)
id := utils.String(frontDoorPath + "/FrontendEndpoints/" + name)

Expand All @@ -805,6 +810,12 @@ func expandArmFrontDoorFrontendEndpoint(input []interface{}, frontDoorPath strin
},
}

if waf != "" {
result.FrontendEndpointProperties.WebApplicationFirewallPolicyLink = &frontdoor.FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink{
ID: utils.String(waf),
}
}

output = append(output, result)
}

Expand Down Expand Up @@ -1183,17 +1194,17 @@ func flattenArmFrontDoorFrontendEndpoint(input *[]frontdoor.FrontendEndpoint, re
}

if sessionAffinityEnabled := properties.SessionAffinityEnabledState; sessionAffinityEnabled != "" {
if sessionAffinityEnabled == frontdoor.SessionAffinityEnabledStateEnabled {
result["session_affinity_enabled"] = true
} else {
result["session_affinity_enabled"] = false
}
result["session_affinity_enabled"] = sessionAffinityEnabled == frontdoor.SessionAffinityEnabledStateEnabled
}

if sessionAffinityTtlSeconds := properties.SessionAffinityTTLSeconds; sessionAffinityTtlSeconds != nil {
result["session_affinity_ttl_seconds"] = *sessionAffinityTtlSeconds
}

if waf := properties.WebApplicationFirewallPolicyLink; waf != nil {
result["web_application_firewall_policy_link_id"] = *waf.ID
}

if properties.CustomHTTPSConfiguration != nil {
customHTTPSConfiguration := properties.CustomHTTPSConfiguration
if customHTTPSConfiguration.CertificateSource == frontdoor.CertificateSourceAzureKeyVault {
Expand Down
Loading