-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
azurerm_new_relic_monitor
- support monitored_subscription
property
#28134
Open
teowa
wants to merge
10
commits into
hashicorp:main
Choose a base branch
from
teowa:newrelic_monitor_sub
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,359
−17
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d7978eb
support monitored_subscription
teowa 81f830a
fix error message
teowa 6c37d4b
use delete method if monitor_subscription is removed
teowa 2248ddb
fix
teowa 02efb5b
fix
teowa 0733270
fix error message and refresh
teowa 8c24a20
fix wait method
teowa e84f41b
fix lint
teowa e3ed0c4
remove wait
teowa 33e9509
fix client
teowa 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
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
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 |
---|---|---|
|
@@ -98,6 +98,52 @@ func TestAccNewRelicMonitor_identity(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccNewRelicMonitor_monitoredSubscription(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "azurerm_new_relic_monitor", "test") | ||
r := NewRelicMonitorResource{} | ||
effectiveDate := time.Now().Add(time.Hour * 7).Format(time.RFC3339) | ||
email := "[email protected]" | ||
data.ResourceTest(t, r, []acceptance.TestStep{ | ||
{ | ||
Config: r.monitoredSubscription(data, effectiveDate, email), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep(), | ||
}) | ||
} | ||
|
||
func TestAccNewRelicMonitor_monitoredSubscriptionUpdate(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "azurerm_new_relic_monitor", "test") | ||
r := NewRelicMonitorResource{} | ||
effectiveDate := time.Now().Add(time.Hour * 7).Format(time.RFC3339) | ||
email := "[email protected]" | ||
data.ResourceTest(t, r, []acceptance.TestStep{ | ||
{ | ||
Config: r.basic(data, effectiveDate, email), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep(), | ||
{ | ||
Config: r.monitoredSubscription(data, effectiveDate, email), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep(), | ||
{ | ||
Config: r.basic(data, effectiveDate, email), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep(), | ||
}) | ||
} | ||
|
||
func (r NewRelicMonitorResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { | ||
id, err := monitors.ParseMonitorID(state.ID) | ||
if err != nil { | ||
|
@@ -247,3 +293,35 @@ resource "azurerm_role_assignment" "test" { | |
} | ||
`, template, data.RandomInteger, data.Locations.Primary, effectiveDate, email) | ||
} | ||
|
||
func (r NewRelicMonitorResource) monitoredSubscription(data acceptance.TestData, effectiveDate string, email string) string { | ||
template := r.template(data) | ||
return fmt.Sprintf(` | ||
%s | ||
|
||
data "azurerm_subscription" "test" { | ||
subscription_id = "%s" | ||
} | ||
|
||
resource "azurerm_new_relic_monitor" "test" { | ||
name = "acctest-nrm-%d" | ||
resource_group_name = azurerm_resource_group.test.name | ||
location = "%s" | ||
plan { | ||
effective_date = "%s" | ||
} | ||
user { | ||
email = "%s" | ||
first_name = "first" | ||
last_name = "last" | ||
phone_number = "123456" | ||
} | ||
identity { | ||
type = "SystemAssigned" | ||
} | ||
monitored_subscription { | ||
subscription_id = data.azurerm_subscription.test.subscription_id | ||
} | ||
} | ||
`, template, data.Subscriptions.Secondary, data.RandomInteger, data.Locations.Primary, effectiveDate, email) | ||
} |
Oops, something went wrong.
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.
This is not flattened because there are other properties in the monitoredSubscription but not supported by API for now and they might be supported in the future.