-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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 Data Source/Resource: azurerm_cdn_frontdoor_origin_group
/ New Resource: azurerm_cdn_frontdoor_origin
#17089
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2c0f40f
New Resource: `azurerm_cdn_frontdoor_endpoint`
tombuildsstuff 6d2edfb
cdn: generating the ID Parsers/Validators for CDN FrontDoor Origin & …
tombuildsstuff 6d5bbe3
New Resource: `azurerm_cdn_frontdoor_origin_group`
tombuildsstuff eefd37e
New Data Source: `azurerm_cdn_frontdoor_origin_group`
tombuildsstuff 1f186a0
New Resource: `azurerm_cdn_frontdoor_origin`
tombuildsstuff c9163aa
refactor: linting
tombuildsstuff 0d1d917
Merge branch 'main' into f/cdn-frontdoor-origin-and-groups
WodansSon a102c0b
Make name check required
WodansSon 3ff2fe1
fix rule set datasource test
WodansSon 2869a49
fix test case part duex
WodansSon bc0a929
Fix test part wej
WodansSon a878d7c
v3.14.0
katbyte 62f3f33
addressing PR comment
WodansSon 6c62b4d
Merge branch 'main' of https://github.com/hashicorp/terraform-provide…
WodansSon 3f73092
go mod tidy
WodansSon 7b573cf
Update changelog
WodansSon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## 3.14.0 (Unreleased) | ||
## 3.15.0 (Unreleased) | ||
|
||
FEATURES: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
144 changes: 144 additions & 0 deletions
144
internal/services/cdn/cdn_frontdoor_origin_group_data_source.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
package cdn | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" | ||
|
||
"github.com/hashicorp/terraform-provider-azurerm/internal/clients" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/services/cdn/parse" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/services/cdn/validate" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" | ||
"github.com/hashicorp/terraform-provider-azurerm/utils" | ||
) | ||
|
||
func dataSourceCdnFrontDoorOriginGroup() *pluginsdk.Resource { | ||
return &pluginsdk.Resource{ | ||
Read: dataSourceCdnFrontDoorOriginGroupRead, | ||
|
||
Timeouts: &pluginsdk.ResourceTimeout{ | ||
Read: pluginsdk.DefaultTimeout(5 * time.Minute), | ||
}, | ||
|
||
Schema: map[string]*pluginsdk.Schema{ | ||
"name": { | ||
Type: pluginsdk.TypeString, | ||
Required: true, | ||
ValidateFunc: validate.FrontDoorOriginGroupName, | ||
}, | ||
|
||
"profile_name": { | ||
Type: pluginsdk.TypeString, | ||
Required: true, | ||
ValidateFunc: validate.FrontDoorName, | ||
}, | ||
|
||
"resource_group_name": commonschema.ResourceGroupNameForDataSource(), | ||
|
||
// Computed | ||
"cdn_frontdoor_profile_id": { | ||
Type: pluginsdk.TypeString, | ||
Computed: true, | ||
}, | ||
|
||
"health_probe": { | ||
Type: pluginsdk.TypeList, | ||
Computed: true, | ||
Elem: &pluginsdk.Resource{ | ||
Schema: map[string]*pluginsdk.Schema{ | ||
"interval_in_seconds": { | ||
Type: pluginsdk.TypeInt, | ||
Computed: true, | ||
}, | ||
"path": { | ||
Type: pluginsdk.TypeString, | ||
Computed: true, | ||
}, | ||
"protocol": { | ||
Type: pluginsdk.TypeString, | ||
Computed: true, | ||
}, | ||
|
||
"request_type": { | ||
Type: pluginsdk.TypeString, | ||
Computed: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
||
"load_balancing": { | ||
Type: pluginsdk.TypeList, | ||
Computed: true, | ||
Elem: &pluginsdk.Resource{ | ||
Schema: map[string]*pluginsdk.Schema{ | ||
"additional_latency_in_milliseconds": { | ||
Type: pluginsdk.TypeInt, | ||
Computed: true, | ||
}, | ||
|
||
"sample_size": { | ||
Type: pluginsdk.TypeInt, | ||
Computed: true, | ||
}, | ||
|
||
"successful_samples_required": { | ||
Type: pluginsdk.TypeInt, | ||
Computed: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
||
"restore_traffic_time_to_healed_or_new_endpoint_in_minutes": { | ||
Type: pluginsdk.TypeInt, | ||
Computed: true, | ||
}, | ||
|
||
"session_affinity_enabled": { | ||
Type: pluginsdk.TypeBool, | ||
Computed: true, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceCdnFrontDoorOriginGroupRead(d *pluginsdk.ResourceData, meta interface{}) error { | ||
client := meta.(*clients.Client).Cdn.FrontDoorOriginGroupsClient | ||
subscriptionId := meta.(*clients.Client).Account.SubscriptionId | ||
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) | ||
defer cancel() | ||
|
||
id := parse.NewFrontDoorOriginGroupID(subscriptionId, d.Get("resource_group_name").(string), d.Get("profile_name").(string), d.Get("name").(string)) | ||
resp, err := client.Get(ctx, id.ResourceGroup, id.ProfileName, id.OriginGroupName) | ||
if err != nil { | ||
if utils.ResponseWasNotFound(resp.Response) { | ||
return fmt.Errorf("%s was not found", id) | ||
} | ||
|
||
return fmt.Errorf("retrieving %s: %+v", id, err) | ||
} | ||
|
||
d.SetId(id.ID()) | ||
d.Set("name", id.OriginGroupName) | ||
d.Set("profile_name", id.ProfileName) | ||
d.Set("resource_group_name", id.ResourceGroup) | ||
d.Set("cdn_frontdoor_profile_id", parse.NewFrontDoorProfileID(id.SubscriptionId, id.ResourceGroup, id.ProfileName).ID()) | ||
|
||
if props := resp.AFDOriginGroupProperties; props != nil { | ||
if err := d.Set("health_probe", flattenCdnFrontDoorOriginGroupHealthProbeParameters(props.HealthProbeSettings)); err != nil { | ||
return fmt.Errorf("setting `health_probe`: %+v", err) | ||
} | ||
|
||
if err := d.Set("load_balancing", flattenCdnFrontDoorOriginGroupLoadBalancingSettingsParameters(props.LoadBalancingSettings)); err != nil { | ||
return fmt.Errorf("setting `load_balancing`: %+v", err) | ||
} | ||
|
||
d.Set("session_affinity_enabled", flattenEnabledBool(props.SessionAffinityState)) | ||
d.Set("restore_traffic_time_to_healed_or_new_endpoint_in_minutes", props.TrafficRestorationTimeToHealedOrNewEndpointsInMinutes) | ||
} | ||
|
||
return nil | ||
} |
37 changes: 37 additions & 0 deletions
37
internal/services/cdn/cdn_frontdoor_origin_group_data_source_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package cdn_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" | ||
) | ||
|
||
type CdnFrontDoorOriginGroupDataSource struct{} | ||
|
||
func TestAccCdnFrontDoorOriginGroupDataSource_basic(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "data.azurerm_cdn_frontdoor_origin_group", "test") | ||
d := CdnFrontDoorOriginGroupDataSource{} | ||
|
||
data.DataSourceTest(t, []acceptance.TestStep{ | ||
{ | ||
Config: d.basic(data), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).Key("cdn_frontdoor_profile_id").MatchesOtherKey(check.That("azurerm_cdn_frontdoor_profile.test").Key("id")), | ||
), | ||
}, | ||
}) | ||
} | ||
|
||
func (CdnFrontDoorOriginGroupDataSource) basic(data acceptance.TestData) string { | ||
return fmt.Sprintf(` | ||
%s | ||
|
||
data "azurerm_cdn_frontdoor_origin_group" "test" { | ||
name = azurerm_cdn_frontdoor_origin_group.test.name | ||
profile_name = azurerm_cdn_frontdoor_profile.test.name | ||
resource_group_name = azurerm_cdn_frontdoor_profile.test.resource_group_name | ||
} | ||
`, CdnFrontDoorOriginGroupResource{}.complete(data)) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you will have to roll back the merge main
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.