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

Add primary & secondary connection string to 'azurerm_iothub_dps_shared_access_policy' #5231

Merged
merged 204 commits into from
Dec 31, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
204 commits
Select commit Hold shift + click to select a range
f4ac2be
Add primary & secondary connection string to DPS Shared Access Policy
Dec 20, 2019
6275c9b
Update website
Dec 20, 2019
961d4a9
nil check properties
Dec 30, 2019
54b30c3
Simplify logic for setting connection strings
Brunhil Dec 31, 2019
5e2868b
Move analysis services
mbfrahry Dec 19, 2019
ae46841
apimanagement
mbfrahry Dec 19, 2019
00d4c3b
appconfiguration
mbfrahry Dec 19, 2019
b913a79
applicationinsights
mbfrahry Dec 19, 2019
11f8468
authorization
mbfrahry Dec 19, 2019
20d4c07
automation
mbfrahry Dec 19, 2019
15753bd
batch
mbfrahry Dec 19, 2019
b93df7c
bot
mbfrahry Dec 19, 2019
2611c08
cdn
mbfrahry Dec 19, 2019
d912e25
cognitive
mbfrahry Dec 19, 2019
826ceb2
compute
mbfrahry Dec 20, 2019
381c4c8
containers
mbfrahry Dec 20, 2019
de4a8d7
cosmos
mbfrahry Dec 20, 2019
03ff182
databricks
mbfrahry Dec 20, 2019
2e998cb
datafactory
mbfrahry Dec 20, 2019
ea54594
datalake
mbfrahry Dec 20, 2019
d9ddcc6
devspace
mbfrahry Dec 20, 2019
4af58d7
devtestlabs
mbfrahry Dec 20, 2019
878dfc1
dns
mbfrahry Dec 20, 2019
018ddc7
dns-final
mbfrahry Dec 20, 2019
b039ee2
eventgrid
mbfrahry Dec 20, 2019
b66b97b
eventhub
mbfrahry Dec 20, 2019
7359c49
frontdoor
mbfrahry Dec 20, 2019
4247c43
hdinsight
mbfrahry Dec 20, 2019
de6ef7b
healthcare
mbfrahry Dec 20, 2019
1819243
iothub
mbfrahry Dec 20, 2019
3c88faa
kusot
mbfrahry Dec 20, 2019
d374836
loganalytics
mbfrahry Dec 20, 2019
166b05c
logic
mbfrahry Dec 20, 2019
7b125a6
managementgroup
mbfrahry Dec 20, 2019
c7d4582
maps
mbfrahry Dec 20, 2019
6f11989
mariadb
mbfrahry Dec 20, 2019
e63eb77
media
mbfrahry Dec 20, 2019
f2877f6
monitor
mbfrahry Dec 20, 2019
022c432
msi
mbfrahry Dec 20, 2019
c54d4e8
mysql
mbfrahry Dec 20, 2019
7baaaa2
netapp
mbfrahry Dec 20, 2019
fa14baf
network
mbfrahry Dec 20, 2019
e246bc6
notificationhub
katbyte Dec 20, 2019
7b815ce
policy
katbyte Dec 20, 2019
2d71fe3
postgres
katbyte Dec 20, 2019
d0411d5
privatedns
katbyte Dec 20, 2019
77fdecb
recoveryservices
katbyte Dec 20, 2019
6eea249
redis
katbyte Dec 20, 2019
378ac28
relay
katbyte Dec 20, 2019
606491e
scheduler
katbyte Dec 20, 2019
1170b71
search
katbyte Dec 20, 2019
f6dd945
securitycenter
katbyte Dec 20, 2019
0f21bd5
servicebus
katbyte Dec 20, 2019
ffb3c57
servicefabric
katbyte Dec 20, 2019
e0be2b5
signalr
katbyte Dec 20, 2019
f5d958c
sql
katbyte Dec 20, 2019
f3bc717
mssql
katbyte Dec 20, 2019
9fff7aa
streamanalytics
katbyte Dec 20, 2019
6f93208
web
katbyte Dec 20, 2019
e921100
more networking
katbyte Dec 20, 2019
34c43a4
trafficmanager
katbyte Dec 20, 2019
dfac32e
subscription
katbyte Dec 20, 2019
148d429
keyvault
katbyte Dec 20, 2019
9a73efa
storage
katbyte Dec 20, 2019
544b42d
resource 2
katbyte Dec 20, 2019
78b2804
more compute pls
katbyte Dec 20, 2019
53fa403
network 2
katbyte Dec 20, 2019
e760eb8
additional authorization
katbyte Dec 20, 2019
d7a1215
remaining resource
katbyte Dec 20, 2019
1507aac
portal
katbyte Dec 20, 2019
e0f9d1b
more monitor
katbyte Dec 20, 2019
7cc74f5
sql: moving the testdata into the package folder
tombuildsstuff Dec 20, 2019
aebb7bf
apimanagement: moving the testdata folder
tombuildsstuff Dec 20, 2019
06ce5c8
testdata: moving into packages
tombuildsstuff Dec 20, 2019
0168697
d/client_config: moving into the authorization package
tombuildsstuff Dec 20, 2019
3311b27
provider: cleaning up the remaining top-level functions
tombuildsstuff Dec 20, 2019
c0991c9
signalr: fixing the tests
tombuildsstuff Dec 20, 2019
7860a16
fix test failures
katbyte Dec 20, 2019
d86ba0e
refactor: removing a circular reference by moving the init to provider
tombuildsstuff Dec 20, 2019
1c8950c
compute: moving proximity placement group to the right package
tombuildsstuff Dec 20, 2019
229cd03
resource: fixing the `azurerm_resources` test
tombuildsstuff Dec 20, 2019
8488c5a
compute: fixing the compile errors
tombuildsstuff Dec 20, 2019
cfce06b
r/mssql_server_security_alert_policy: adding a local CheckDestroy func
tombuildsstuff Dec 20, 2019
42ff444
r/mssql_database_vulnerability_assessment_rule_baseline: switching to…
tombuildsstuff Dec 20, 2019
b8c3a31
r/(montitor_)metric_alert_rule: switching to a local template func
tombuildsstuff Dec 20, 2019
4485dcc
r/mssql_server_vulnerability_assessment: fixing tests
tombuildsstuff Dec 20, 2019
9b3d13d
provider: moving the init func
tombuildsstuff Dec 20, 2019
9806e33
resources: moving the tests into their own package
tombuildsstuff Dec 20, 2019
3817b9f
web: updating the tests
tombuildsstuff Dec 20, 2019
b8b9996
trafficmanager: switching to use the new test structure
tombuildsstuff Dec 20, 2019
1f693cc
subscription: switching over to use the new test builder
tombuildsstuff Dec 20, 2019
2de39d7
streamanalytics: switching to the new structure
tombuildsstuff Dec 20, 2019
f7ab7fc
test analysisservices
mbfrahry Dec 20, 2019
28a412a
apimanagement
mbfrahry Dec 20, 2019
c4b8598
tests: appconfiguration
mbfrahry Dec 20, 2019
92ba59a
loganalytics: switching to the new structure
katbyte Dec 20, 2019
04a90a9
logic: switching to the new structure
katbyte Dec 20, 2019
72edf7c
compute: switching to the new structure
katbyte Dec 21, 2019
c02e7fa
maps: switching to the new test structure
katbyte Dec 21, 2019
274f4b0
managementgroup: switching to the new test structure
katbyte Dec 21, 2019
3f504a9
mariadb: switching to the new test structure
katbyte Dec 21, 2019
b2aec96
tests: storage
mbfrahry Dec 21, 2019
52489d3
sql
mbfrahry Dec 21, 2019
cda964b
signalr
mbfrahry Dec 21, 2019
a24ecaf
tests: servicefabric
mbfrahry Dec 21, 2019
709db97
test: servicebus
mbfrahry Dec 21, 2019
62f59d2
media: switching to the new test structure
katbyte Dec 21, 2019
1f81e8b
monitor: switching to the new test structure
katbyte Dec 21, 2019
f9afb9a
msi: switching to the new test structure
katbyte Dec 21, 2019
02a7f08
mssql: switching to the new test structure
katbyte Dec 21, 2019
8034366
mysql: switching to the new test structure
katbyte Dec 21, 2019
aa418a7
fixing the tests
tombuildsstuff Dec 21, 2019
fe5dfff
removing a circular reference in the provider tests
tombuildsstuff Dec 21, 2019
7d27e23
securitycenter: switching over to the new test structure
tombuildsstuff Dec 21, 2019
1e49901
search: switching to use the new structure
tombuildsstuff Dec 21, 2019
e25e563
scheduler: fixing up the tests
tombuildsstuff Dec 21, 2019
6b81a14
relay: fixing up the tests
tombuildsstuff Dec 21, 2019
7326489
redis: switching to use the new test structure
tombuildsstuff Dec 21, 2019
e347514
recoveryservices: fixing the tests
tombuildsstuff Dec 21, 2019
b878ad3
privatedns: fixing the tests
tombuildsstuff Dec 21, 2019
00cfa63
postgres: fixing the tests
tombuildsstuff Dec 21, 2019
d488702
portal: fixing the tests
tombuildsstuff Dec 21, 2019
a48795d
policy: fixing the tests
tombuildsstuff Dec 21, 2019
aeb3310
notificationhub: fixing the tests
tombuildsstuff Dec 21, 2019
c615578
netapp: switching to the new test structure
katbyte Dec 21, 2019
81f8a92
kusto: switching to the new test structure
katbyte Dec 21, 2019
2746415
servicebus: fixing up a file that was missed
tombuildsstuff Dec 21, 2019
1160237
applicationinsights
mbfrahry Dec 21, 2019
226da63
keyvault: switching to the new test structure
katbyte Dec 21, 2019
534bf7d
move keyvault testdata into tests package
katbyte Dec 21, 2019
1952ab5
compute: fixing the remnants
tombuildsstuff Dec 21, 2019
58abad0
iothub: switching to the new test structure
katbyte Dec 21, 2019
bcbafb8
tests: authorization
mbfrahry Dec 21, 2019
fb0542b
healthcare: fixing the tests
tombuildsstuff Dec 21, 2019
6f5097d
tests: automation
mbfrahry Dec 21, 2019
e37031d
hdinsight: porting over to the new test helper
tombuildsstuff Dec 21, 2019
7a7ac3a
tests: batch
mbfrahry Dec 21, 2019
3d9264e
hdinsight: fixing the type
tombuildsstuff Dec 21, 2019
931ecf1
network: switching to the new test structure
katbyte Dec 21, 2019
8b258f4
move batch testdata into tests package
katbyte Dec 21, 2019
ac32aec
move eventhub testdata into tests package
katbyte Dec 21, 2019
2a2c542
move eventgrid testdata into tests package
katbyte Dec 21, 2019
aaa5f00
tests: bot
mbfrahry Dec 21, 2019
dd8f99b
dns: switching to the new test structure
katbyte Dec 21, 2019
24ba657
devtestlabs: switching to the new test structure
katbyte Dec 21, 2019
5a7a658
frontdoor: fixing up the tests
tombuildsstuff Dec 21, 2019
1e5e1bf
acceptance: fixing compiler errors
tombuildsstuff Dec 21, 2019
74f2e9a
devspace: switching to the new test structure
katbyte Dec 21, 2019
69ca31c
datalake: switching to the new test structure
katbyte Dec 21, 2019
7f394b4
move datalake testdata into tests package
katbyte Dec 21, 2019
05cce79
datafactory: switching to the new test structure
katbyte Dec 21, 2019
310f59c
databricks: switching to the new test structure
katbyte Dec 21, 2019
0a9df22
cosmos: switching to the new test structure
katbyte Dec 21, 2019
9d649a0
containers: switching to the new test structure
katbyte Dec 21, 2019
a667fb3
cognitive: switching to the new test structure
katbyte Dec 21, 2019
fb33b2a
cdn: switching to the new test structure
katbyte Dec 21, 2019
c5398a7
graph: switching to the new test structure
katbyte Dec 21, 2019
de8a708
fix error in resource_arm_batch_pool_test.go
katbyte Dec 21, 2019
69bcc11
storage migrations: switching to the new test structure
katbyte Dec 21, 2019
619b42c
fix goimport and whitespace errors
katbyte Dec 21, 2019
c58e28d
fix linting errors
katbyte Dec 21, 2019
4f27962
GOGC=5 for linting
katbyte Dec 21, 2019
9d638de
try and fix travis OOM error
katbyte Dec 22, 2019
660c865
travis: temporarily disabling travis2 and travis3
tombuildsstuff Dec 23, 2019
feb3fef
refactor: sorting the keys in the registration structs
tombuildsstuff Dec 23, 2019
e70fbb5
timeouts: fixing the timeouts script to handle the refactor
tombuildsstuff Dec 23, 2019
7ab6787
registry: adding a check for an empty category
tombuildsstuff Dec 23, 2019
cedaf85
Fix mistakes and add additional example
BHoggs Dec 19, 2019
92cf359
tests: misc cleanup after test reorg (#5239)
katbyte Dec 25, 2019
fe8218a
azurerm_logic_app_trigger_recurrence - support for start_time (#5244)
aqche Dec 26, 2019
eef8472
Update CHANGELOG.md to include #5244
katbyte Dec 26, 2019
7d58850
Add new resource & data source: azurerm_netapp_snapshot (#5215)
Dec 26, 2019
4425ac0
Update CHANGELOG.md to include #5215
katbyte Dec 26, 2019
3da46fa
New Resource: `azurerm_kusto_database_principal` (#5242)
mbfrahry Dec 26, 2019
622b6e8
Update CHANGELOG.md to include #5242
katbyte Dec 26, 2019
637d5e0
provider: omiting logging during acctests (#5241)
tombuildsstuff Dec 26, 2019
5f07128
attempt to fix travis 1
katbyte Dec 23, 2019
cc33a32
attempt 2
katbyte Dec 23, 2019
650f3c6
try 3
katbyte Dec 24, 2019
a391ec9
try 4
katbyte Dec 24, 2019
2ced912
try again
katbyte Dec 24, 2019
61934e6
try again
katbyte Dec 24, 2019
71e0b55
try again
katbyte Dec 25, 2019
dbc83cb
try again
katbyte Dec 25, 2019
c6e146e
try try try again
katbyte Dec 25, 2019
f06504e
removed unused linter
katbyte Dec 25, 2019
f161e21
fix cfg file path
katbyte Dec 25, 2019
c744074
fail build for info to open issue with
katbyte Dec 25, 2019
4c3beb5
try including static check
katbyte Dec 26, 2019
294c6f6
remove seperate staticcheck linting
katbyte Dec 26, 2019
76df86d
increase golang-ci deadling to 60m
katbyte Dec 26, 2019
b7e57b8
New Resource `azurerm_cosmosdb_gremlin_database` (#5248)
SebRosander Dec 26, 2019
d0e21a9
Update CHANGELOG.md to include #5248
katbyte Dec 26, 2019
16c2a2a
Fix wrong doc items for nat-gateway
ArcturusZhang Dec 27, 2019
5f9cfbb
remove concurancy argument from travis linting command so config file…
katbyte Dec 27, 2019
ea1b1ef
post-refactor: fixing a couple of test failures (#5267)
tombuildsstuff Dec 28, 2019
4c0b594
provider - fix various test failures from the refactoring (#5262)
katbyte Dec 28, 2019
c9feb60
New Resource: `azurerm_api_management_identity_provider_aad` (#5268)
aqche Dec 30, 2019
b2fdea1
Update CHANGELOG.md to include #5268
katbyte Dec 30, 2019
c6386d1
Fix panic in 'azurerm_api_management_operation' (#5273)
Brunhil Dec 30, 2019
1a6f973
Update CHANGELOG.md to include #5273
katbyte Dec 30, 2019
0978968
Fix reference to 'resourceName'
Dec 31, 2019
e9d6261
Merge branch 'master' into add_iothubdps_sap_conn_string
Brunhil Dec 31, 2019
f557dc4
fmt file
Dec 31, 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
29 changes: 29 additions & 0 deletions azurerm/resource_arm_iothub_dps_shared_access_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,23 @@ func resourceArmIotHubDPSSharedAccessPolicy() *schema.Resource {
Computed: true,
},

"primary_connection_string": {
Type: schema.TypeString,
Sensitive: true,
Computed: true,
},

"secondary_key": {
Type: schema.TypeString,
Sensitive: true,
Computed: true,
},

"secondary_connection_string": {
Type: schema.TypeString,
Sensitive: true,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -201,6 +213,11 @@ func resourceArmIotHubDPSSharedAccessPolicyRead(d *schema.ResourceData, meta int
iothubDpsName := id.Path["provisioningServices"]
keyName := id.Path["keys"]

iothubDps, err := client.Get(ctx, iothubDpsName, resourceGroup)
if err != nil {
return fmt.Errorf("Error retrieving IotHub DPS %q (Resource Group %q): %+v", iothubDpsName, resourceGroup, err)
}

accessPolicy, err := client.ListKeysForKeyName(ctx, iothubDpsName, keyName, resourceGroup)
if err != nil {
if utils.ResponseWasNotFound(accessPolicy.Response) {
Expand All @@ -217,6 +234,14 @@ func resourceArmIotHubDPSSharedAccessPolicyRead(d *schema.ResourceData, meta int
d.Set("primary_key", accessPolicy.PrimaryKey)
d.Set("secondary_key", accessPolicy.SecondaryKey)

if err := d.Set("primary_connection_string", getSAPConnectionString(*iothubDps.Properties.ServiceOperationsHostName, keyName, *accessPolicy.PrimaryKey)); err != nil {
jackbatzner marked this conversation as resolved.
Show resolved Hide resolved
return fmt.Errorf("error setting `primary_connection_string`: %v", err)
}

if err := d.Set("secondary_connection_string", getSAPConnectionString(*iothubDps.Properties.ServiceOperationsHostName, keyName, *accessPolicy.SecondaryKey)); err != nil {
return fmt.Errorf("error setting `secondary_connection_string`: %v", err)
}

rights := flattenDpsAccessRights(accessPolicy.Rights)
d.Set("enrollment_read", rights.enrollmentRead)
d.Set("enrollment_write", rights.enrollmentWrite)
Expand Down Expand Up @@ -369,3 +394,7 @@ func flattenDpsAccessRights(r iothub.AccessRightsDescription) dpsAccessRights {

return rights
}

func getSAPConnectionString(iothubDpsHostName string, keyName string, key string) string {
return fmt.Sprintf("HostName=%s;SharedAccessKeyName=%s;SharedAccessKey=%s", iothubDpsHostName, keyName, key)
}
4 changes: 4 additions & 0 deletions azurerm/resource_arm_iothub_dps_shared_access_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ func TestAccAzureRMIotHubDpsSharedAccessPolicy_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "registration_read", "false"),
resource.TestCheckResourceAttr(resourceName, "registration_write", "false"),
resource.TestCheckResourceAttr(resourceName, "service_config", "true"),
resource.TestCheckResourceAttrSet(resourceName, "primary_key"),
resource.TestCheckResourceAttrSet(resourceName, "primary_connection_string"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_key"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_connection_string"),
),
},
},
Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/iothub_dps_shared_access_policy.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ The following attributes are exported:

* `primary_key` - The primary key used to create the authentication token.

* `primary_connection_string` - The primary connection string of the Shared Access Policy.

* `secondary_key` - The secondary key used to create the authentication token.

* `secondary_connection_string` - The secondary connection string of the Shared Access Policy.

## Import

IoT Hub Device Provisioning Service Shared Access Policies can be imported using the `resource id`, e.g.
Expand Down