Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion .github/workflows/contract-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
flex-cluster: ${{ steps.filter.outputs.flex-cluster }}
online-archive: ${{ steps.filter.outputs.online-archive }}
organization: ${{ steps.filter.outputs.organization }}
service-account: ${{ steps.filter.outputs.service-account }}
private-endpoint-aws: ${{ steps.filter.outputs.private-endpoint-aws }}
private-endpoint-service: ${{ steps.filter.outputs.private-endpoint-service }}
privatelink-endpoint-service-data-federation-online-archive: ${{ steps.filter.outputs.privatelink-endpoint-service-data-federation-online-archive }}
Expand Down Expand Up @@ -61,6 +62,8 @@ jobs:
- 'cfn-resources/online-archive/**'
organization:
- 'cfn-resources/organization/**'
service-account:
- 'cfn-resources/service-account/**'
private-endpoint-aws:
- 'cfn-resources/private-endpoint-aws/**'
private-endpoint-service:
Expand Down Expand Up @@ -525,7 +528,48 @@ jobs:
run: |
pushd cfn-resources/organization
make create-test-resources


cat inputs/inputs_1_create.json
cat inputs/inputs_1_update.json

make run-contract-testing
make delete-test-resources
service-account:
needs: change-detection
if: ${{ needs.change-detection.outputs.service-account == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5
with:
go-version-file: 'cfn-resources/go.mod'
- name: setup Atlas CLI
uses: mongodb/atlas-github-action@e3c9e0204659bafbb3b65e1eb1ee745cca0e9f3b
- uses: aws-actions/setup-sam@c2a20b1822cc4a6bc594ff7f1dbb658758e383c3
with:
use-installer: true
- uses: aws-actions/configure-aws-credentials@61815dcd50bd041e203e49132bacad1fd04d2708
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_TEST_ENV }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_TEST_ENV }}
aws-region: eu-west-1
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548
with:
python-version: '3.9'
cache: 'pip' # caching pip dependencies
- run: pip install cloudformation-cli cloudformation-cli-go-plugin
- name: Run the Contract test
shell: bash
env:
MONGODB_ATLAS_PUBLIC_API_KEY: ${{ secrets.CLOUD_DEV_PUBLIC_KEY }}
MONGODB_ATLAS_PRIVATE_API_KEY: ${{ secrets.CLOUD_DEV_PRIVATE_KEY }}
MONGODB_ATLAS_ORG_ID: ${{ secrets.CLOUD_DEV_ORG_ID }}
MONGODB_ATLAS_OPS_MANAGER_URL: ${{ vars.MONGODB_ATLAS_BASE_URL }}
MONGODB_ATLAS_PROFILE: cfn-cloud-dev-github-action
run: |
cd cfn-resources/service-account
make create-test-resources

cat inputs/inputs_1_create.json
cat inputs/inputs_1_update.json

Expand Down
27 changes: 27 additions & 0 deletions cfn-resources/service-account/.rpdk-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"artifact_type": "RESOURCE",
"typeName": "MongoDB::Atlas::ServiceAccount",
"language": "go",
"runtime": "provided.al2",
"entrypoint": "bootstrap",
"testEntrypoint": "bootstrap",
"settings": {
"version": false,
"subparser_name": null,
"verbose": 0,
"force": false,
"type_name": null,
"artifact_type": null,
"endpoint_url": null,
"region": null,
"target_schemas": [],
"profile": null,
"import_path": "github.com/mongodb/mongodbatlas-cloudformation-resources/service-account",
"protocolVersion": "2.0.0"
},
"canarySettings": {
"contract_test_file_names": [
"inputs_1.json"
]
}
}
37 changes: 37 additions & 0 deletions cfn-resources/service-account/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.PHONY: build test clean debug create-test-resources delete-test-resources run-contract-testing
tags=logging callback metrics scheduler
cgo=0
goos=linux
goarch=amd64
CFNREP_GIT_SHA?=$(shell git rev-parse HEAD)
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}
ldXflagsD=-X github.com/mongodb/mongodbatlas-cloudformation-resources/util.defaultLogLevel=debug -X github.com/mongodb/mongodbatlas-cloudformation-resources/version.Version=${CFNREP_GIT_SHA}

build:
cfn generate
env GOOS=$(goos) CGO_ENABLED=$(cgo) GOARCH=$(goarch) go build -ldflags="$(ldXflags)" -tags="$(tags)" -o bin/bootstrap cmd/main.go

debug:
cfn generate
env GOOS=$(goos) CGO_ENABLED=$(cgo) GOARCH=$(goarch) go build -ldflags="$(ldXflagsD)" -tags="$(tags)" -o bin/bootstrap cmd/main.go

test:
cfn generate
env GOOS=$(goos) go build -ldflags="-s -w" -tags="$(tags)" -o bin/bootstrap cmd/main.go

clean:
rm -rf bin

create-test-resources:
@echo "==> Creating test files and resources for contract testing"
./test/contract-testing/cfn-test-create.sh

delete-test-resources:
@echo "==> Delete test resources used for contract testing"
./test/contract-testing/cfn-test-delete.sh

run-contract-testing:
@echo "==> Run contract testing"
make build
sam local start-lambda &
cfn test --function-name TestEntrypoint --verbose
19 changes: 19 additions & 0 deletions cfn-resources/service-account/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# MongoDB::Atlas::ServiceAccount

## Description

Resource for managing [Service Accounts](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/group/endpoint-service-accounts) for a MongoDB Atlas organization. Service accounts provide programmatic access to MongoDB Atlas resources and are used for automation, CI/CD pipelines, and service-to-service authentication.

## Requirements

To securely give CloudFormation access to your Atlas credentials, you must
set up an [AWS Profile](/README.md#mongodb-atlas-api-keys-credential-management).

## Attributes and Parameters

See the [resource docs](docs/README.md).

## Cloudformation Examples

See the examples [CFN Template](/examples/service-account/README.md) for example resource.

85 changes: 85 additions & 0 deletions cfn-resources/service-account/cmd/main.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions cfn-resources/service-account/cmd/resource/config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading