Skip to content

Commit c7357d1

Browse files
INTMDB-571: POST Create Access List Entries for One Organization API Key endpoint supports list, but Terraform does not (#1065)
* Add example for multiple IP and CIDR blocks * Tidy up variables * Update examples/atlas-ip-access-list/main.tf Co-authored-by: Zuhair Ahmed <[email protected]> * Update examples/atlas-ip-access-list/main.tf Co-authored-by: Zuhair Ahmed <[email protected]> --------- Co-authored-by: Zuhair Ahmed <[email protected]>
1 parent 53e7756 commit c7357d1

File tree

5 files changed

+85
-0
lines changed

5 files changed

+85
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# MongoDB Atlas Provider -- Atlas IP Access List
2+
This example creates a project API access list showing how to attach multiple IP addresses and CIDR Blocks.
3+
4+
Variables Required to be set:
5+
- `project_id`: ID of the Atlas project
6+
- `public_key`: Atlas public key
7+
- `private_key`: Atlas private key
8+
- `ip_address`: IP addresses you want to permit access to
9+
- `cidr_block`: CIDR block you want to permit access to
10+
- `comment`: If provider_name is tenant, the backing provider (AWS, GCP)
11+
12+
13+
For this example, we will setup two access ranges to show multiple IP support and multiple CIDR block.
14+
15+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
locals {
2+
3+
ip_address_list = [
4+
{
5+
ip_address = "47.225.213.178"
6+
comment = "IP Address 1"
7+
},
8+
9+
{
10+
ip_address = "47.225.214.179"
11+
comment = "IP Address 2"
12+
},
13+
]
14+
15+
cidr_block_list = [
16+
{
17+
cidr_block = "10.1.0.0/16"
18+
comment = "CIDR Block 1"
19+
},
20+
{
21+
cidr_block = "12.2.0.0/16"
22+
comment = "CIDR Block 2"
23+
},
24+
]
25+
}
26+
27+
28+
resource "mongodbatlas_project_ip_access_list" "ip" {
29+
for_each = {
30+
for index, ip in local.ip_address_list :
31+
ip.comment => ip
32+
}
33+
project_id = var.project_id
34+
ip_address = each.value.ip_address
35+
comment = each.value.comment
36+
}
37+
38+
39+
resource "mongodbatlas_project_ip_access_list" "cidr" {
40+
41+
for_each = {
42+
for index, cidr in local.cidr_block_list :
43+
cidr.comment => cidr
44+
}
45+
project_id = var.project_id
46+
cidr_block = each.value.cidr_block
47+
comment = each.value.comment
48+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
provider "mongodbatlas" {
2+
public_key = var.public_key
3+
private_key = var.private_key
4+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
variable "public_key" {
2+
description = "Public API key to authenticate to Atlas"
3+
}
4+
variable "private_key" {
5+
description = "Private API key to authenticate to Atlas"
6+
}
7+
variable "project_id" {
8+
description = "Atlas project name"
9+
default = ""
10+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
terraform {
2+
required_providers {
3+
mongodbatlas = {
4+
source = "mongodb/mongodbatlas"
5+
}
6+
}
7+
required_version = ">= 0.13"
8+
}

0 commit comments

Comments
 (0)