Skip to content

Commit d11a8ce

Browse files
feat: CLOUDP-380114 Add Project Service Account Access List Entry (#1581)
Co-authored-by: Rakhul S Prakash <rakhul.s.prakash@peerislands.io>
1 parent b4e8a76 commit d11a8ce

24 files changed

Lines changed: 1152 additions & 0 deletions

.github/workflows/contract-testing.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
project: ${{ steps.filter.outputs.project }}
3939
project-service-account-secret: ${{ steps.filter.outputs.project-service-account-secret }}
4040
project-service-account: ${{ steps.filter.outputs.project-service-account }}
41+
project-service-account-access-list-entry: ${{ steps.filter.outputs.project-service-account-access-list-entry }}
4142
resource-policy: ${{ steps.filter.outputs.resource-policy }}
4243
search-deployment: ${{ steps.filter.outputs.search-deployment }}
4344
search-index: ${{ steps.filter.outputs.search-index }}
@@ -108,6 +109,8 @@ jobs:
108109
- 'cfn-resources/project-service-account-secret/**'
109110
project-service-account:
110111
- 'cfn-resources/project-service-account/**'
112+
project-service-account-access-list-entry:
113+
- 'cfn-resources/project-service-account-access-list-entry/**'
111114
resource-policy:
112115
- 'cfn-resources/resource-policy/**'
113116
search-deployment:
@@ -1235,6 +1238,47 @@ jobs:
12351238
make run-contract-testing
12361239
make delete-test-resources
12371240
1241+
project-service-account-access-list-entry:
1242+
needs: change-detection
1243+
if: ${{ needs.change-detection.outputs.project-service-account-access-list-entry == 'true' }}
1244+
runs-on: ubuntu-latest
1245+
steps:
1246+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
1247+
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5
1248+
with:
1249+
go-version-file: 'cfn-resources/go.mod'
1250+
- name: setup Atlas CLI
1251+
uses: mongodb/atlas-github-action@e3c9e0204659bafbb3b65e1eb1ee745cca0e9f3b
1252+
- uses: aws-actions/setup-sam@d78e1a4a9656d3b223e59b80676a797f20093133
1253+
with:
1254+
use-installer: true
1255+
- uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7
1256+
with:
1257+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_TEST_ENV }}
1258+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_TEST_ENV }}
1259+
aws-region: eu-west-1
1260+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
1261+
with:
1262+
python-version: '3.9'
1263+
cache: 'pip' # caching pip dependencies
1264+
- run: pip install cloudformation-cli cloudformation-cli-go-plugin
1265+
- name: Run the Contract test
1266+
shell: bash
1267+
env:
1268+
MONGODB_ATLAS_PUBLIC_API_KEY: ${{ secrets.CLOUD_DEV_PUBLIC_KEY }}
1269+
MONGODB_ATLAS_PRIVATE_API_KEY: ${{ secrets.CLOUD_DEV_PRIVATE_KEY }}
1270+
MONGODB_ATLAS_ORG_ID: ${{ secrets.CLOUD_DEV_ORG_ID }}
1271+
MONGODB_ATLAS_OPS_MANAGER_URL: ${{ vars.MONGODB_ATLAS_BASE_URL }}
1272+
MONGODB_ATLAS_PROFILE: cfn-cloud-dev-github-action
1273+
run: |
1274+
cd cfn-resources/project-service-account-access-list-entry
1275+
make create-test-resources
1276+
1277+
cat inputs/*
1278+
1279+
make run-contract-testing
1280+
make delete-test-resources
1281+
12381282
resource-policy:
12391283
needs: change-detection
12401284
if: ${{ needs.change-detection.outputs.resource-policy == 'true' }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"typeName": "MongoDB::Atlas::ProjectServiceAccountAccessListEntry",
3+
"language": "go",
4+
"runtime": "provided.al2",
5+
"entrypoint": "bootstrap",
6+
"testEntrypoint": "bootstrap",
7+
"settings": {
8+
"import_path": "github.com/mongodb/mongodbatlas-cloudformation-resources/project-service-account-access-list-entry",
9+
"protocolVersion": "2.0.0",
10+
"pluginVersion": "2.0.4"
11+
}
12+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.PHONY: build test clean
2+
tags=logging callback metrics scheduler
3+
cgo=0
4+
goos=linux
5+
goarch=amd64
6+
CFNREP_GIT_SHA?=$(shell git rev-parse HEAD)
7+
ldXflags=-s -w -X github.com/mongodb/mongodbatlas-cloudformation-resources/util.defaultLogLevel=info -X github.com/mongodb/mongodbatlas-cloudformation-resources/version.Version=${CFNREP_GIT_SHA}
8+
ldXflagsD=-X github.com/mongodb/mongodbatlas-cloudformation-resources/util.defaultLogLevel=debug -X github.com/mongodb/mongodbatlas-cloudformation-resources/version.Version=${CFNREP_GIT_SHA}
9+
10+
build:
11+
cfn generate
12+
env GOOS=$(goos) CGO_ENABLED=$(cgo) GOARCH=$(goarch) go build -ldflags="$(ldXflags)" -tags="$(tags)" -o bin/bootstrap cmd/main.go
13+
14+
debug:
15+
cfn generate
16+
env GOOS=$(goos) CGO_ENABLED=$(cgo) GOARCH=$(goarch) go build -ldflags="$(ldXflagsD)" -tags="$(tags)" -o bin/debug cmd/main.go
17+
18+
clean:
19+
rm -rf bin
20+
21+
submit: clean build # submit to private registry must use release build not debug build
22+
@echo "==> Submitting to private registry for testing"
23+
cfn submit --set-default --region us-east-1
24+
25+
create-test-resources:
26+
@echo "==> Creating test files and resources for contract testing"
27+
./test/contract-testing/cfn-test-create.sh
28+
29+
delete-test-resources:
30+
@echo "==> Delete test resources used for contract testing"
31+
./test/contract-testing/cfn-test-delete.sh
32+
33+
run-contract-testing:
34+
@echo "==> Run contract testing"
35+
make build
36+
sam local start-lambda &
37+
cfn test --function-name TestEntrypoint --verbose
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# MongoDB::Atlas::ProjectServiceAccountAccessListEntry
2+
3+
## Description
4+
5+
The Project Service Account Access List Entry resource manages IP access list entries for MongoDB Atlas Project Service Accounts. This resource lets you create, read, delete, and list IP access list entries at the project level. For more information, see [Create One Project Service Account Access List Entry](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Service-Accounts/operation/createAccessList) in the MongoDB Atlas API documentation.
6+
7+
-> **NOTE:** This resource does not support updates. Any property change will trigger a replacement (delete + create).
8+
9+
## Requirements
10+
11+
To securely give CloudFormation access to your Atlas credentials, you must
12+
set up an [AWS Profile](/README.md#mongodb-atlas-api-keys-credential-management).
13+
14+
## Attributes and Parameters
15+
16+
See the [resource docs](docs/README.md).
17+
18+
## Cloudformation Examples
19+
20+
See the example [CFN Template](/examples/project-service-account-access-list-entry/README.md) for example resource.
21+
22+
## Important Notes
23+
24+
- You must specify either `CIDRBlock` or `IPAddress`, but not both
25+
- When you specify an IP address, Atlas automatically generates a `/32` CIDR block
26+
- This resource does not support updates - any change will trigger a replacement
27+
- Access list entries are identified by the combination of `ProjectId`, `ClientId`, and `CIDRBlock`
28+
- The List operation returns all access list entries for a given project service account

cfn-resources/project-service-account-access-list-entry/cmd/main.go

Lines changed: 85 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cfn-resources/project-service-account-access-list-entry/cmd/resource/config.go

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)