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: azurerm_bastion_host #4096

Merged
merged 24 commits into from
Oct 10, 2019
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
41727bf
initial changes
DanielMabbett Aug 15, 2019
28058d6
go fmt
DanielMabbett Aug 15, 2019
6e01472
adding tests and links for website
DanielMabbett Aug 15, 2019
689269b
update markdown bastion host
DanielMabbett Aug 15, 2019
09eb3a2
remove incompatible and unrequired files/folders
DanielMabbett Aug 15, 2019
78a5dfe
add dns_name argument for bastion host
DanielMabbett Aug 15, 2019
155cb39
cleanup
DanielMabbett Aug 15, 2019
f5a752b
cleanup bastion host test
DanielMabbett Aug 15, 2019
1edfd63
cleanup bastion host resource
DanielMabbett Aug 15, 2019
f15620c
Seperate Bastion into Networking preview api
DanielMabbett Aug 15, 2019
016c73e
remove non-useful comments
DanielMabbett Aug 15, 2019
4ca2e3a
Merge branch 'master' into feature/azure-bastion-host
DanielMabbett Aug 16, 2019
3d8f633
Merge branch 'master' into feature/azure-bastion-host
DanielMabbett Aug 20, 2019
29007a9
Update go.mod
DanielMabbett Aug 20, 2019
21f37e7
bastion: add expand and flatten for ipconfig. Fix typos and errs. Add…
DanielMabbett Oct 3, 2019
6da56d0
init
DanielMabbett Oct 7, 2019
8aeb4c7
working tests. Notes for Bastion Markdown
DanielMabbett Oct 7, 2019
1bd394d
Merge branch 'master' of https://github.com/terraform-providers/terra…
DanielMabbett Oct 7, 2019
b467b95
Merge branch 'feature/azure-bastion-host' into feature/azure-bastion-…
DanielMabbett Oct 7, 2019
35f6880
Merge pull request #1 from DanielMabbett/feature/azure-bastion-host-a…
DanielMabbett Oct 7, 2019
8efb4ef
update with pull from upstream
DanielMabbett Oct 7, 2019
3765ff8
go fmt provider.go for travis ci err
DanielMabbett Oct 8, 2019
9d4326d
move dns_name, expandipconfig pointer return, import test add, rename…
DanielMabbett Oct 9, 2019
8c26237
remove whitespace
DanielMabbett Oct 10, 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
Prev Previous commit
Next Next commit
update with pull from upstream
DanielMabbett committed Oct 7, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 8efb4ef84e26ffd94a81547a3815b0405646cc70
34 changes: 25 additions & 9 deletions azurerm/resource_arm_bastion_host.go
Original file line number Diff line number Diff line change
@@ -5,14 +5,12 @@ import (
"log"
"regexp"

"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags"

"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2019-06-01/network"
"github.com/hashicorp/terraform/helper/schema"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/response"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

@@ -51,8 +49,9 @@ func resourceArmBastionHost() *schema.Resource {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
Type: schema.TypeString,
Required: true,
ValidateFunc: validateAzureRMBastionIPConfigName,
},
DanielMabbett marked this conversation as resolved.
Show resolved Hide resolved
"subnet_id": {
Type: schema.TypeString,
@@ -74,7 +73,7 @@ func resourceArmBastionHost() *schema.Resource {
}

func resourceArmBastionHostCreateUpdate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ArmClient).network.BastionHostsClient
client := meta.(*ArmClient).Network.BastionHostsClient
ctx := meta.(*ArmClient).StopContext

log.Println("[INFO] preparing arguments for Azure Bastion Host creation.")
@@ -126,7 +125,7 @@ func resourceArmBastionHostCreateUpdate(d *schema.ResourceData, meta interface{}
}

func resourceArmBastionHostRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ArmClient).network.BastionHostsClient
client := meta.(*ArmClient).Network.BastionHostsClient
ctx := meta.(*ArmClient).StopContext

id, err := azure.ParseAzureResourceID(d.Id())
@@ -169,7 +168,7 @@ func resourceArmBastionHostRead(d *schema.ResourceData, meta interface{}) error
}

func resourceArmBastionHostDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ArmClient).network.BastionHostsClient
client := meta.(*ArmClient).Network.BastionHostsClient
ctx := meta.(*ArmClient).StopContext

id, err := parseAzureResourceID(d.Id())
@@ -211,6 +210,23 @@ func validateAzureRMBastionHostName(v interface{}, k string) (warnings []string,
return warnings, errors
}

func validateAzureRMBastionIPConfigName(v interface{}, k string) (warnings []string, errors []error) {
value := v.(string)
if !regexp.MustCompile(`^[a-zA-Z0-9]+$`).MatchString(value) {
errors = append(errors, fmt.Errorf("lowercase letters, highercase letters numbers only are allowed in %q: %q", k, value))
}

if 1 > len(value) {
errors = append(errors, fmt.Errorf("%q cannot be less than 1 characters: %q", k, value))
}

if len(value) > 32 {
errors = append(errors, fmt.Errorf("%q cannot be longer than 32 characters: %q %d", k, value, len(value)))
}

return warnings, errors
}

func expandArmBastionHostIPConfiguration(input []interface{}) (ipConfigs []network.BastionHostIPConfiguration) {
if len(input) == 0 {
return nil
12 changes: 6 additions & 6 deletions azurerm/resource_arm_bastion_host_test.go
Original file line number Diff line number Diff line change
@@ -2,14 +2,14 @@ package azurerm

import (
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
"testing"
)

func TestAccAzureRMBastionHost_basic(t *testing.T) {
@@ -197,7 +197,7 @@ resource "azurerm_bastion_host" "import" {

func testCheckAzureRMBastionHostExists(resourceName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
client := testAccProvider.Meta().(*ArmClient).network.BastionHostsClient
client := testAccProvider.Meta().(*ArmClient).Network.BastionHostsClient
ctx := testAccProvider.Meta().(*ArmClient).StopContext

rs, ok := s.RootModule().Resources[resourceName]
@@ -221,7 +221,7 @@ func testCheckAzureRMBastionHostExists(resourceName string) resource.TestCheckFu
}

func testCheckAzureRMBastionHostDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*ArmClient).network.BastionHostsClient
client := testAccProvider.Meta().(*ArmClient).Network.BastionHostsClient
ctx := testAccProvider.Meta().(*ArmClient).StopContext

for _, rs := range s.RootModule().Resources {