Skip to content

Commit ae0303e

Browse files
sivaram-mongodbsivaram-mongodb
andauthored
feat: CLOUDP-380115 Add MongoDb Employee Access Grant resource (#1584)
Co-authored-by: sivaram-mongodb <sivaram@mongodb.com>
1 parent 532eccb commit ae0303e

22 files changed

Lines changed: 983 additions & 0 deletions

.github/workflows/contract-testing.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
federated-settings-org-role-mapping: ${{ steps.filter.outputs.federated-settings-org-role-mapping }}
2727
flex-cluster: ${{ steps.filter.outputs.flex-cluster }}
2828
log-integration: ${{ steps.filter.outputs.log-integration }}
29+
mongodb-employee-access-grant: ${{ steps.filter.outputs.mongodb-employee-access-grant }}
2930
online-archive: ${{ steps.filter.outputs.online-archive }}
3031
organization: ${{ steps.filter.outputs.organization }}
3132
service-account: ${{ steps.filter.outputs.service-account }}
@@ -85,6 +86,8 @@ jobs:
8586
- 'cfn-resources/flex-cluster/**'
8687
log-integration:
8788
- 'cfn-resources/log-integration/**'
89+
mongodb-employee-access-grant:
90+
- 'cfn-resources/mongodb-employee-access-grant/**'
8891
online-archive:
8992
- 'cfn-resources/online-archive/**'
9093
organization:
@@ -704,6 +707,7 @@ jobs:
704707
705708
make run-contract-testing
706709
make delete-test-resources
710+
707711
log-integration:
708712
needs: change-detection
709713
if: ${{ needs.change-detection.outputs.log-integration == 'true' }}
@@ -744,6 +748,48 @@ jobs:
744748
745749
make run-contract-testing
746750
make delete-test-resources
751+
752+
mongodb-employee-access-grant:
753+
needs: change-detection
754+
if: ${{ needs.change-detection.outputs.mongodb-employee-access-grant == 'true' }}
755+
runs-on: ubuntu-latest
756+
steps:
757+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
758+
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5
759+
with:
760+
go-version-file: 'cfn-resources/go.mod'
761+
- name: setup Atlas CLI
762+
uses: mongodb/atlas-github-action@e3c9e0204659bafbb3b65e1eb1ee745cca0e9f3b
763+
- uses: aws-actions/setup-sam@d78e1a4a9656d3b223e59b80676a797f20093133
764+
with:
765+
use-installer: true
766+
- uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7
767+
with:
768+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_TEST_ENV }}
769+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_TEST_ENV }}
770+
aws-region: eu-west-1
771+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
772+
with:
773+
python-version: '3.9'
774+
cache: 'pip'
775+
- run: pip install cloudformation-cli cloudformation-cli-go-plugin
776+
- name: Run the Contract test
777+
shell: bash
778+
env:
779+
MONGODB_ATLAS_PUBLIC_API_KEY: ${{ secrets.CLOUD_DEV_PUBLIC_KEY }}
780+
MONGODB_ATLAS_PRIVATE_API_KEY: ${{ secrets.CLOUD_DEV_PRIVATE_KEY }}
781+
MONGODB_ATLAS_ORG_ID: ${{ secrets.CLOUD_DEV_ORG_ID }}
782+
MONGODB_ATLAS_OPS_MANAGER_URL: ${{ vars.MONGODB_ATLAS_BASE_URL }}
783+
MONGODB_ATLAS_PROFILE: cfn-cloud-dev-github-action
784+
run: |
785+
pushd cfn-resources/mongodb-employee-access-grant
786+
make create-test-resources
787+
788+
cat inputs/*
789+
790+
make run-contract-testing
791+
make delete-test-resources
792+
747793
online-archive:
748794
needs: change-detection
749795
if: ${{ needs.change-detection.outputs.online-archive == 'true' }}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"artifact_type": "RESOURCE",
3+
"typeName": "MongoDB::Atlas::MongoDbEmployeeAccessGrant",
4+
"language": "go",
5+
"runtime": "provided.al2",
6+
"entrypoint": "bootstrap",
7+
"testEntrypoint": "bootstrap",
8+
"settings": {
9+
"version": false,
10+
"subparser_name": null,
11+
"verbose": 0,
12+
"force": false,
13+
"type_name": null,
14+
"artifact_type": null,
15+
"endpoint_url": null,
16+
"region": null,
17+
"target_schemas": [],
18+
"profile": null,
19+
"import_path": "github.com/mongodb/mongodbatlas-cloudformation-resources/mongodb-employee-access-grant",
20+
"protocolVersion": "2.0.0"
21+
},
22+
"canarySettings": {
23+
"contract_test_file_names": [
24+
"inputs_1.json"
25+
]
26+
}
27+
}
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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# MongoDB::Atlas::MongoDbEmployeeAccessGrant
2+
3+
## Description
4+
5+
Resource for managing [MongoDB Employee Access Grants](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-grantgroupclustermongodbemployeeaccess) for Atlas clusters. This resource grants temporary access to MongoDB employees for a specific cluster, allowing MongoDB support engineers to access cluster infrastructure, database logs, or app services sync data for troubleshooting purposes.
6+
7+
## Requirements
8+
9+
To securely give CloudFormation access to your Atlas credentials, you must
10+
set up an [AWS Profile](/README.md#mongodb-atlas-api-keys-credential-management).
11+
12+
## Attributes and Parameters
13+
14+
See the [resource docs](docs/README.md).
15+
16+
## Cloudformation Examples
17+
18+
See the examples [CFN Template](/examples/mongodb-employee-access-grant/README.md) for example resource.

cfn-resources/mongodb-employee-access-grant/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/mongodb-employee-access-grant/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)