Skip to content

Commit

Permalink
- meraki_networks panics on creation if the organization id is invalid
Browse files Browse the repository at this point in the history
…#101

- wireless identity psk configuration works but the output showing bug error #89
  • Loading branch information
fmunozmiranda committed Jul 10, 2024
1 parent fbf570f commit 9be383e
Show file tree
Hide file tree
Showing 48 changed files with 575 additions and 306 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

resource "meraki_networks_wireless_ssids_identity_psks" "example" {

expires_at = "2018-02-11T00:00:00.090210Z"
expires_at = "2018-02-11T00:00:00.090209Z"
group_policy_id = "101"
name = "Sample Identity PSK"
network_id = "string"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import meraki_networks_group_policies.example "group_policy_id,network_id"
149 changes: 149 additions & 0 deletions examples/samples/resources/meraki_networks_group_policies/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
terraform {
required_providers {
meraki = {
version = "0.2.5-alpha"
source = "hashicorp.com/edu/meraki"
# "hashicorp.com/edu/meraki" is the local built source, change to "cisco-en-programmability/meraki" to use downloaded version from registry
}
}
}
provider "meraki" {
meraki_debug = "true"
}


resource "meraki_networks_group_policies" "example" {

bandwidth = {

bandwidth_limits = {

limit_down = 1000000
limit_up = 1000000
}
settings = "custom"
}
bonjour_forwarding = {

rules = [{

description = "A simple bonjour rule"
services = ["All Services"]
vlan_id = "1"
}]
settings = "custom"
}
content_filtering = {

allowed_url_patterns = {

settings = "network default"
}
blocked_url_categories = {

# categories = ["meraki:contentFiltering/category/1", "meraki:contentFiltering/category/7"]
settings = "override"
}
blocked_url_patterns = {

patterns = ["http://www.example.com", "http://www.betting.com"]
settings = "append"
}
}
firewall_and_traffic_shaping = {

l3_firewall_rules = [{

comment = "Allow TCP traffic to subnet with HTTP servers."
dest_cidr = "192.168.1.0/24"
dest_port = "443"
policy = "allow"
protocol = "tcp"
}]
l7_firewall_rules = [{

policy = "deny"
type = "host"
value = "google.com"
}]
settings = "custom"
traffic_shaping_rules = [{

definitions = [{

type = "host"
value = "google.com"
}]
# dscp_tag_value = 1
pcp_tag_value = 1
per_client_bandwidth_limits = {

bandwidth_limits = {

limit_down = 1000000
limit_up = 1000000
}
settings = "custom"
}
priority = "normal"
}]
}
name = "No video streaming"
network_id = "L_828099381482775375"
scheduling = {

enabled = true
friday = {

active = true
from = "9:00"
to = "17:00"
}
monday = {

active = true
from = "9:00"
to = "17:00"
}
saturday = {

active = true
from = "9:00"
to = "17:00"
}
sunday = {

active = true
from = "9:00"
to = "17:00"
}
thursday = {

active = true
from = "9:00"
to = "17:00"
}
tuesday = {

active = true
from = "9:00"
to = "17:00"
}
wednesday = {

active = true
from = "9:00"
to = "17:00"
}
}
splash_auth_settings = "bypass"
vlan_tagging = {

settings = "custom"
vlan_id = "1"
}
}

output "meraki_networks_group_policies_example" {
value = meraki_networks_group_policies.example
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import meraki_networks_wireless_ssids_identity_psks.example "identity_psk_id,network_id,number"
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
terraform {
required_providers {
meraki = {
version = "0.2.5-alpha"
source = "hashicorp.com/edu/meraki"
# "hashicorp.com/edu/meraki" is the local built source, change to "cisco-en-programmability/meraki" to use downloaded version from registry
}
}
}

provider "meraki" {
meraki_debug = "true"
}


resource "meraki_networks_wireless_ssids_identity_psks" "example" {
# lifecycle {
# # ignore_changes = [ expires_at ]
# }
expires_at = "2018-02-11T00:00:00.090209Z"
group_policy_id = "100"
name = "Sample Identity PSK"
network_id = "L_828099381482775375"
number = "12"
passphrase = "secret1221121"
}

output "meraki_networks_wireless_ssids_identity_psks_example" {
value = meraki_networks_wireless_ssids_identity_psks.example
}
17 changes: 10 additions & 7 deletions internal/provider/resource_meraki_devices_live_tools_arp_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,18 @@ func (r *DevicesLiveToolsArpTableResource) Create(ctx context.Context, req resou
if vvArpTableID != "" {
responseVerifyItem, restyResp1, err := r.client.Devices.GetDeviceLiveToolsArpTable(vvSerial, vvArpTableID)
//Have Create
if err != nil || restyResp1 == nil {
if restyResp1.StatusCode() != 404 {
resp.Diagnostics.AddError(
"Failure when executing GetDeviceLiveToolsArpTable",
err.Error(),
)
return
if err != nil {
if restyResp1 != nil {
if restyResp1.StatusCode() != 404 {
resp.Diagnostics.AddError(
"Failure when executing GetDeviceLiveToolsArpTable",
err.Error(),
)
return
}
}
}

if responseVerifyItem != nil {
data := ResponseDevicesGetDeviceLiveToolsArpTableItemToBodyRs(data, responseVerifyItem, false)
//Path params in update assigned
Expand Down
16 changes: 9 additions & 7 deletions internal/provider/resource_meraki_devices_live_tools_cable.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,15 @@ func (r *DevicesLiveToolsCableResource) Create(ctx context.Context, req resource

responseVerifyItem, restyResp1, err := r.client.Devices.GetDeviceLiveToolsCableTest(vvSerial, vvID)
//Have Create
if err != nil || restyResp1 == nil {
if restyResp1.StatusCode() != 404 {
resp.Diagnostics.AddError(
"Failure when executing GetDeviceLiveToolsCableTest",
err.Error(),
)
return
if err != nil {
if restyResp1 != nil {
if restyResp1.StatusCode() != 404 {
resp.Diagnostics.AddError(
"Failure when executing GetDeviceLiveToolsCableTest",
err.Error(),
)
return
}
}
}
if responseVerifyItem != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,15 @@ func (r *DevicesLiveToolsThroughputTestResource) Create(ctx context.Context, req
if vvThroughputTestID != "" {
responseVerifyItem, restyResp1, err := r.client.Devices.GetDeviceLiveToolsThroughputTest(vvSerial, vvThroughputTestID)
//Have Create
if err != nil || restyResp1 == nil {
if restyResp1.StatusCode() != 404 {
resp.Diagnostics.AddError(
"Failure when executing GetDeviceLiveToolsThroughputTest",
err.Error(),
)
return
if err != nil {
if restyResp1 != nil {
if restyResp1.StatusCode() != 404 {
resp.Diagnostics.AddError(
"Failure when executing GetDeviceLiveToolsThroughputTest",
err.Error(),
)
return
}
}
}
if responseVerifyItem != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,15 @@ func (r *DevicesLiveToolsWakeOnLanResource) Create(ctx context.Context, req reso
if vvWakeOnLanID != "" {
responseVerifyItem, restyResp1, err := r.client.Devices.GetDeviceLiveToolsWakeOnLan(vvSerial, vvWakeOnLanID)
//Have Create
if err != nil || restyResp1 == nil {
if restyResp1.StatusCode() != 404 {
resp.Diagnostics.AddError(
"Failure when executing GetDeviceLiveToolsWakeOnLan",
err.Error(),
)
return
if err != nil {
if restyResp1 != nil {
if restyResp1.StatusCode() != 404 {
resp.Diagnostics.AddError(
"Failure when executing GetDeviceLiveToolsWakeOnLan",
err.Error(),
)
return
}
}
}
if responseVerifyItem != nil {
Expand Down
20 changes: 11 additions & 9 deletions internal/provider/resource_meraki_devices_management_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,17 @@ func (r *DevicesManagementInterfaceResource) Create(ctx context.Context, req res
//Item
responseVerifyItem, restyResp1, err := r.client.Devices.GetDeviceManagementInterface(vvSerial)
//Have Create
if err != nil || restyResp1 == nil {
if restyResp1 == nil {
resp.Diagnostics.AddError(
"Failure when executing Get",
err.Error(),
)
return
}
if restyResp1.StatusCode() != 404 {
if err != nil {
if restyResp1 != nil {
if restyResp1 == nil {
resp.Diagnostics.AddError(
"Failure when executing Get",
err.Error(),
)
return
}
if restyResp1.StatusCode() != 404 {
}
resp.Diagnostics.AddError(
"Failure when executing GetDeviceManagementInterface",
err.Error(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,15 @@ func (r *DevicesSwitchRoutingInterfacesResource) Create(ctx context.Context, req
//Items
responseVerifyItem, restyResp1, err := r.client.Switch.GetDeviceSwitchRoutingInterfaces(vvSerial)
//Have Create
if err != nil || restyResp1 == nil {
if restyResp1.StatusCode() != 404 {
resp.Diagnostics.AddError(
"Failure when executing GetDeviceSwitchRoutingInterfaces",
err.Error(),
)
return
if err != nil {
if restyResp1 != nil {
if restyResp1.StatusCode() != 404 {
resp.Diagnostics.AddError(
"Failure when executing GetDeviceSwitchRoutingInterfaces",
err.Error(),
)
return
}
}
}
if responseVerifyItem != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,15 @@ func (r *DevicesSwitchRoutingStaticRoutesResource) Create(ctx context.Context, r
//Items
responseVerifyItem, restyResp1, err := r.client.Switch.GetDeviceSwitchRoutingStaticRoutes(vvSerial)
//Have Create
if err != nil || restyResp1 == nil {
if restyResp1.StatusCode() != 404 {
resp.Diagnostics.AddError(
"Failure when executing GetDeviceSwitchRoutingStaticRoutes",
err.Error(),
)
return
if err != nil {
if restyResp1 != nil {
if restyResp1.StatusCode() != 404 {
resp.Diagnostics.AddError(
"Failure when executing GetDeviceSwitchRoutingStaticRoutes",
err.Error(),
)
return
}
}
}
if responseVerifyItem != nil {
Expand Down
16 changes: 9 additions & 7 deletions internal/provider/resource_meraki_networks.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,15 @@ func (r *NetworksResource) Create(ctx context.Context, req resource.CreateReques
//Items
responseVerifyItem, restyResp1, err := getAllItemsNetworks(*r.client, vvOrganizationID)
//Have Create
if err != nil || restyResp1 == nil {
if restyResp1.StatusCode() != 404 {
resp.Diagnostics.AddError(
"Failure when executing GetOrganizationNetworks",
err.Error(),
)
return
if err != nil {
if restyResp1 != nil {
if restyResp1.StatusCode() != 404 {
resp.Diagnostics.AddError(
"Failure when executing GetOrganizationNetworks",
err.Error(),
)
return
}
}
}
if responseVerifyItem != nil {
Expand Down
Loading

0 comments on commit 9be383e

Please sign in to comment.