Skip to content

Commit b4e8a76

Browse files
sivaram-mongodbsivaram-mongodb
andauthored
feat: CLOUDP-380112 add service-account-project-assignment resource (#1587)
Co-authored-by: sivaram-mongodb <sivaram@mongodb.com>
1 parent e19a54e commit b4e8a76

22 files changed

Lines changed: 998 additions & 0 deletions

.github/workflows/contract-testing.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
online-archive: ${{ steps.filter.outputs.online-archive }}
3030
organization: ${{ steps.filter.outputs.organization }}
3131
service-account: ${{ steps.filter.outputs.service-account }}
32+
service-account-project-assignment: ${{ steps.filter.outputs.service-account-project-assignment }}
3233
service-account-secret: ${{ steps.filter.outputs.service-account-secret }}
3334
service-account-access-list-entry: ${{ steps.filter.outputs.service-account-access-list-entry }}
3435
private-endpoint-aws: ${{ steps.filter.outputs.private-endpoint-aws }}
@@ -89,6 +90,8 @@ jobs:
8990
- 'cfn-resources/organization/**'
9091
service-account:
9192
- 'cfn-resources/service-account/**'
93+
service-account-project-assignment:
94+
- 'cfn-resources/service-account-project-assignment/**'
9295
service-account-secret:
9396
- 'cfn-resources/service-account-secret/**'
9497
service-account-access-list-entry:
@@ -859,6 +862,47 @@ jobs:
859862
cat inputs/inputs_1_create.json
860863
cat inputs/inputs_1_update.json
861864
865+
make run-contract-testing
866+
make delete-test-resources
867+
service-account-project-assignment:
868+
needs: change-detection
869+
if: ${{ needs.change-detection.outputs.service-account-project-assignment == 'true' }}
870+
runs-on: ubuntu-latest
871+
steps:
872+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
873+
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5
874+
with:
875+
go-version-file: 'cfn-resources/go.mod'
876+
- name: setup Atlas CLI
877+
uses: mongodb/atlas-github-action@e3c9e0204659bafbb3b65e1eb1ee745cca0e9f3b
878+
- uses: aws-actions/setup-sam@d78e1a4a9656d3b223e59b80676a797f20093133
879+
with:
880+
use-installer: true
881+
- uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7
882+
with:
883+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_TEST_ENV }}
884+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_TEST_ENV }}
885+
aws-region: eu-west-1
886+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
887+
with:
888+
python-version: '3.9'
889+
cache: 'pip'
890+
- run: pip install cloudformation-cli cloudformation-cli-go-plugin
891+
- name: Run the Contract test
892+
shell: bash
893+
env:
894+
MONGODB_ATLAS_PUBLIC_API_KEY: ${{ secrets.CLOUD_DEV_PUBLIC_KEY }}
895+
MONGODB_ATLAS_PRIVATE_API_KEY: ${{ secrets.CLOUD_DEV_PRIVATE_KEY }}
896+
MONGODB_ATLAS_ORG_ID: ${{ secrets.CLOUD_DEV_ORG_ID }}
897+
MONGODB_ATLAS_OPS_MANAGER_URL: ${{ vars.MONGODB_ATLAS_BASE_URL }}
898+
MONGODB_ATLAS_PROFILE: cfn-cloud-dev-github-action
899+
run: |
900+
cd cfn-resources/service-account-project-assignment
901+
make create-test-resources
902+
903+
cat inputs/inputs_1_create.json
904+
cat inputs/inputs_1_update.json
905+
862906
make run-contract-testing
863907
make delete-test-resources
864908
service-account-secret:
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::ServiceAccountProjectAssignment",
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/service-account-project-assignment",
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
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::ServiceAccountProjectAssignment
2+
3+
## Description
4+
5+
Resource for assigning [Service Accounts](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/group/endpoint-service-accounts) to MongoDB Atlas projects with specified roles. This resource manages the relationship between a Service Account and a Project, enabling programmatic access to project-level resources through service-to-service authentication.
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/service-account-project-assignment/README.md) for example resource.

cfn-resources/service-account-project-assignment/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-project-assignment/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)