Skip to content

Commit 6a3b944

Browse files
feat: CLOUDP-380113 Add service account access list entry resource (#1580)
Co-authored-by: Rakhul S Prakash <rakhul.s.prakash@peerislands.io>
1 parent 3dec6e1 commit 6a3b944

25 files changed

Lines changed: 1260 additions & 0 deletions

.github/workflows/contract-testing.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
organization: ${{ steps.filter.outputs.organization }}
3131
service-account: ${{ steps.filter.outputs.service-account }}
3232
service-account-secret: ${{ steps.filter.outputs.service-account-secret }}
33+
service-account-access-list-entry: ${{ steps.filter.outputs.service-account-access-list-entry }}
3334
private-endpoint-aws: ${{ steps.filter.outputs.private-endpoint-aws }}
3435
private-endpoint-service: ${{ steps.filter.outputs.private-endpoint-service }}
3536
privatelink-endpoint-service-data-federation-online-archive: ${{ steps.filter.outputs.privatelink-endpoint-service-data-federation-online-archive }}
@@ -89,6 +90,8 @@ jobs:
8990
- 'cfn-resources/service-account/**'
9091
service-account-secret:
9192
- 'cfn-resources/service-account-secret/**'
93+
service-account-access-list-entry:
94+
- 'cfn-resources/service-account-access-list-entry/**'
9295
private-endpoint-aws:
9396
- 'cfn-resources/private-endpoint-aws/**'
9497
private-endpoint-service:
@@ -895,6 +898,48 @@ jobs:
895898
896899
make run-contract-testing
897900
make delete-test-resources
901+
902+
service-account-access-list-entry:
903+
needs: change-detection
904+
if: ${{ needs.change-detection.outputs.service-account-access-list-entry == 'true' }}
905+
runs-on: ubuntu-latest
906+
steps:
907+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
908+
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5
909+
with:
910+
go-version-file: 'cfn-resources/go.mod'
911+
- name: setup Atlas CLI
912+
uses: mongodb/atlas-github-action@e3c9e0204659bafbb3b65e1eb1ee745cca0e9f3b
913+
- uses: aws-actions/setup-sam@d78e1a4a9656d3b223e59b80676a797f20093133
914+
with:
915+
use-installer: true
916+
- uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7
917+
with:
918+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_TEST_ENV }}
919+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_TEST_ENV }}
920+
aws-region: eu-west-1
921+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
922+
with:
923+
python-version: '3.9'
924+
cache: 'pip' # caching pip dependencies
925+
- run: pip install cloudformation-cli cloudformation-cli-go-plugin
926+
- name: Run the Contract test
927+
shell: bash
928+
env:
929+
MONGODB_ATLAS_PUBLIC_API_KEY: ${{ secrets.CLOUD_DEV_PUBLIC_KEY }}
930+
MONGODB_ATLAS_PRIVATE_API_KEY: ${{ secrets.CLOUD_DEV_PRIVATE_KEY }}
931+
MONGODB_ATLAS_ORG_ID: ${{ secrets.CLOUD_DEV_ORG_ID }}
932+
MONGODB_ATLAS_OPS_MANAGER_URL: ${{ vars.MONGODB_ATLAS_BASE_URL }}
933+
MONGODB_ATLAS_PROFILE: cfn-cloud-dev-github-action
934+
run: |
935+
cd cfn-resources/service-account-access-list-entry
936+
make create-test-resources
937+
938+
cat inputs/*
939+
940+
make run-contract-testing
941+
make delete-test-resources
942+
898943
private-endpoint-aws:
899944
needs: change-detection
900945
if: ${{ needs.change-detection.outputs.private-endpoint-aws == 'true' }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"typeName": "MongoDB::Atlas::ServiceAccountAccessListEntry",
3+
"language": "go",
4+
"runtime": "provided.al2",
5+
"entrypoint": "bootstrap",
6+
"testEntrypoint": "bootstrap",
7+
"settings": {
8+
"import_path": "github.com/mongodb/mongodbatlas-cloudformation-resources/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::ServiceAccountAccessListEntry
2+
3+
## Description
4+
5+
The Service Account Access List Entry resource manages IP access list entries for MongoDB Atlas Service Accounts at the organization level. This resource lets you create, read, delete, and list IP access list entries. For more information, see [Create One Service Account Access List Entry](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Service-Accounts/operation/createOrgServiceAccountAccessList) 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/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 `OrgId`, `ClientId`, and `CIDRBlock`
28+
- The List operation returns all access list entries for a given service account

cfn-resources/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/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)