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
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ After the above 2 steps are completed and we've agreed on a path forward:
2. Create a branch with a name that briefly describes your submission
3. Add comments around your new code that explain what's happening
4. Commit and push your changes to your branch then submit a pull request against the current release branch, not master. The naming scheme of the branch is `release-staging-v#.#.#`. **Note**: There will only be one release branch at a time.
5. A repo maintainer will review the your pull request, and may either request additional changes or merge the pull request.
5. A repo maintainer will review your pull request, and may either request additional changes or merge the pull request.

## Requirements

- Resources configurations, specifcally `.rpdk-config` and `Makefile` build commands, are compatible with cloudformation-cli (`cfn`) versions 0.2.34 and above.
- Resources configurations, specifically `.rpdk-config` and `Makefile` build commands, are compatible with cloudformation-cli (`cfn`) versions 0.2.34 and above.


## Code and Test Best Practices

- Each resource is implemented in a seperate directory within `./cfn-resources`. Under each resource directory operations will be implemented in `./cmd/resource/resource.go`, having a separate file `./cmd/resource/mappings.go` for defining conversion logic with respective SDK and CFN models.
- Each resource is implemented in a separate directory within `./cfn-resources`. Under each resource directory operations will be implemented in `./cmd/resource/resource.go`, having a separate file `./cmd/resource/mappings.go` for defining conversion logic with respective SDK and CFN models.
- Associated unit testing files must be defined for conversion logic, and can also exist for other business logic such as handling state transitions. Unit tests are defined under `resource_test` package to minimize coupling.
- [Testify Mock](https://pkg.go.dev/github.com/stretchr/testify/mock) and [Mockery](https://github.com/vektra/mockery) are used for test doubles in unit tests. Mocked interfaces are generated in folder `cfn-resources/testutil/mocksvc`.
- We have a `/test/README.md` for every resource in `cfn-resources`. You will also find [TESTING.md](./TESTING.md) which provides testing practices common to all resources.
Expand Down
2 changes: 1 addition & 1 deletion TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This file contains the steps to follow to test any changes to the CFN resources.
### Prerequisites
- Install [AtlasCLI](https://www.mongodb.com/docs/atlas/cli/stable/install-atlas-cli/) and [configure the default profile](https://www.mongodb.com/docs/atlas/cli/stable/connect-atlas-cli/#select-a-connection-method) on your machine as the scripts use Atlas CLI
- Ensure [AWS CLI](https://aws.amazon.com/cli/), [CFN CLI](https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/what-is-cloudformation-cli.html), [SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html) are installed and configured correctly for your AWS account
- Configure an Atlas profile secret in AWS account with your API keys. Refer [README](../../../README.md) for more information on how to do this
- Configure an Atlas profile secret in AWS account with your API keys. Refer to [README](README.md) for more information on how to do this
- Have Docker running on your machine
- Refer to the prerequisites for your resource in the `cfn-resources/[resource-folder]/test`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ projectId="${1}"
username="${2}"
password="${3}"

jq --arg ProjectId "$projectId" \
jq --arg projectId "$projectId" \
--arg username "$username" \
--arg password "$password" \
'.desiredResourceState.properties.Username?|=$username | .desiredResourceState.properties.Password?|=$password | .desiredResourceState.properties.ProjectId?|=$projectId' \
'.desiredResourceState.Username?|=$username | .desiredResourceState.Password?|=$password | .desiredResourceState.ProjectId?|=$projectId' \
"$(dirname "$0")/databaseuser.sample-cfn-request.json"
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
{
"desiredResourceState" : {
"resourceType" : "MongoDB::Atlas::DatabaseUser",
"properties" : {
"Username" : "Name",
"ProjectId" : "ProjectId",
"Profile" :"",
"DatabaseName": "$external",
"AWSIAMType": "ROLE",
"Roles": [
{ "RoleName": "readWrite",
"DatabaseName": "testdb"
}
],
"Scopes": [
{ "Type": "CLUSTER",
"Name": "testdb"
}
]


}
},
"providerLogGroupName" : "mongodb-atlas-databaseuser-logs",
"previousResourceState": { }
"desiredResourceState" : {
"Username": "Name",
"ProjectId": "ProjectId",
"Profile":"",
"DatabaseName": "$external",
"AWSIAMType": "ROLE",
"Roles": [
{ "RoleName": "readWrite",
"DatabaseName": "testdb"
}
],
"Scopes": [
{ "Type": "CLUSTER",
"Name": "testdb"
}
]
},
"providerLogGroupName" : "mongodb-atlas-databaseuser-logs",
"previousResourceState": { }
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
{
"desiredResourceState" : {
"resourceType" : "MongoDB::Atlas::DatabaseUser",
"properties" : {
"Username" : "Name",
"Password" : "Name",
"ProjectId" : "ProjectId",
"Profile" : "",
"DatabaseName": "admin",
"Roles": [
{ "RoleName": "readWrite",
"DatabaseName": "testdb"
}
],
"Scopes": [
{ "Type": "CLUSTER",
"Name": "testdb"
}
]
}
},
"providerLogGroupName" : "mongodb-atlas-databaseuser-logs",
"previousResourceState": { }
"desiredResourceState" : {
"Username": "Name",
"Password": "Name",
"ProjectId": "ProjectId",
"Profile": "",
"DatabaseName": "admin",
"Roles": [
{ "RoleName": "readWrite",
"DatabaseName": "testdb"
}
],
"Scopes": [
{ "Type": "CLUSTER",
"Name": "testdb"
}
]
},
"providerLogGroupName" : "mongodb-atlas-databaseuser-logs",
"previousResourceState": { }
}
Loading