Skip to content

Commit

Permalink
updated template file, added samconfig file
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu219 committed Nov 8, 2024
1 parent 46d23d9 commit 493da4e
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 17 deletions.
22 changes: 11 additions & 11 deletions INTERNAL_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ Deployment testing for PyPi:
Deployment testing for AWS:
1. For testing of this package, we perform these steps:
* Update .aws file to use a personal aws account credentials
* Create a S3 bucket in the personal aws account
* Set two environment variables:
* export SAM_S3_BUCKET = 'name of the S3 Bucket created'
* export AWS_REGION = 'region of the deployment'
* Upgrade the SemanticVersion in the template.yaml file, eg 1.0.16 -> 1.0.17
* Run the following command:
* Update .aws file to use a personal aws account credentials.
* Create a S3 bucket in the personal aws account.
* In samconfig.toml file update s3_bucket, region parameters.
* Generate credentials in Mongodb atlas portal and update parameter_overrides in samconfig.toml file.
* Upgrade the SemanticVersion in the template.yaml file and s3_prefix in samconfig.toml file
* Run the following commands:
```
sumoappclient -d test -c mongodbatlas.yaml -e aws
sam build
sam package
sam deploy
```
* This deploys the package via a personal aws account onto AWS Serverless Application Repository
2. For production deployment, we perform these steps:
* Update .aws file to use sumocontent aws account credentials
* Upgrade the SemanticVersion in the template.yaml file, eg 1.0.16 -> 1.0.17
* Update the s3_bucket parameter to appdevstore bucket
* Run the following command:
```
sumoappclient -d prod -c mongodbatlas.yaml -e aws
sam publish
```
* This deploys the package via the sumocontent aws account onto AWS Serverless Application Repository
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
python setup.py bdist_wheel
pip uninstall -y sumologic_mongodb_atlas
pip install dist/sumologic_mongodb_atlas-1.0.11*.whl
43 changes: 38 additions & 5 deletions packaged.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ Metadata:
- atlas
- serverless
- MongoDBAtlas
LicenseUrl: s3://appdevstore/MongoDBAtlas/v1.0.17/5122657d5b9a0d3713e24d3a33eae431
LicenseUrl: s3://appdevstore/MongoDBAtlas/v1.0.18/5122657d5b9a0d3713e24d3a33eae431
Name: sumologic-mongodb-atlas
ReadmeUrl: s3://appdevstore/MongoDBAtlas/v1.0.17/3088978c83fe207a640a2584aff2c79d
SemanticVersion: 1.0.17
ReadmeUrl: s3://appdevstore/MongoDBAtlas/v1.0.18/3088978c83fe207a640a2584aff2c79d
SemanticVersion: 1.0.18
SourceCodeUrl: https://github.com/SumoLogic/sumologic-mongodb-atlas
SpdxLicenseId: Apache-2.0
Outputs:
Expand All @@ -28,6 +28,10 @@ Outputs:
Fn::GetAtt:
- MongoDBAtlasFunction
- Arn
MongoDBAtlasTable:
Description: MongoDBAtlasTable DynamoDB Table Name
Value:
Ref: MongoDBAtlasTableResource
Parameters:
HttpLogsEndpoint:
Type: String
Expand All @@ -44,9 +48,11 @@ Parameters:
Resources:
MongoDBAtlasFunction:
Properties:
CodeUri: s3://appdevstore/MongoDBAtlas/v1.0.17/56c4530782ed537044f71da21d57b605
CodeUri: s3://appdevstore/MongoDBAtlas/v1.0.18/5c5c3a5bfa0831572f5452a56ebc0b20
Environment:
Variables:
DBNAME:
Ref: MongoDBAtlasTableResource
ENABLE_CONSOLE_LOG: 'false'
ENVIRONMENT: aws
HTTP_LOGS_ENDPOINT:
Expand All @@ -69,10 +75,37 @@ Resources:
Handler: main.main
MemorySize: 256
Policies:
- AmazonDynamoDBFullAccess
- Statement:
- Action:
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:GetItem
- dynamodb:Scan
- dynamodb:Query
- dynamodb:DescribeTable
Effect: Allow
Resource:
Fn::GetAtt:
- MongoDBAtlasTableResource
- Arn
Version: '2012-10-17'
Runtime: python3.11
Timeout: 900
Type: AWS::Serverless::Function
Metadata:
SamResourceId: MongoDBAtlasFunction
MongoDBAtlasTableResource:
Properties:
AttributeDefinitions:
- AttributeName: key_col
AttributeType: S
KeySchema:
- AttributeName: key_col
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 30
WriteCapacityUnits: 20
Type: AWS::DynamoDB::Table
Metadata:
SamResourceId: MongoDBAtlasTableResource
Transform: AWS::Serverless-2016-10-31
45 changes: 45 additions & 0 deletions samconfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
version = 0.1

[default.build]
[default.build.parameters]
cached = true
parallel = true
debug=true
use_container=true

[default.package]
[default.package.parameters]
output_template_file="packaged.yaml"
s3_prefix="MongoDBAtlas/v1.0.18"
region="us-east-1"
s3_bucket="appdevstore-test"

[default.deploy.parameters]
capabilities = "CAPABILITY_IAM"
confirm_changeset = true
stack_name="testingMongoDBAtlas"
parameter_overrides="HttpLogsEndpoint=<http logs source endpoint> HttpMetricsEndpoint=<http metrics source endpoint> OrganizationId=<mongodbatlas org id> PrivateApiKey=<mongodbatlas private api key> ProjectId=<mongodb atlas cluster project id> PublicApiKey=<mongodbatlas public api key>"
s3_prefix="MongoDBAtlas/v1.0.18"
region="us-east-1"
s3_bucket="appdevstore-test"

[default.publish.parameters]
template="packaged.yaml"
region="us-east-1"

[default.sync.parameters]
watch = true

[default.local_start_api.parameters]
warm_containers = "EAGER"

[default.local_invoke.parameters]
parameter_overrides="ENVIRONMENT=onprem HttpLogsEndpoint=<http logs source endpoint> HttpMetricsEndpoint=<http metrics source endpoint> OrganizationId=<mongodbatlas org id> PrivateApiKey=<mongodbatlas private api key> ProjectId=<mongodb atlas cluster project id> PublicApiKey=<mongodbatlas public api key>"

# https://github.com/aws/aws-sam-cli/issues/5492
# Allow specification of parameters that should apply to all (or multiple) environments in AWS SAM CLI configuration file (samconfig.toml)

[prod]
[prod.sync]
[prod.sync.parameters]
watch = false
2 changes: 1 addition & 1 deletion template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Parameters:
Resources:
MongoDBAtlasFunction:
Properties:
CodeUri: ./target/aws/build/
CodeUri: ./sumomongodbatlascollector
Environment:
Variables:
DBNAME:
Expand Down

0 comments on commit 493da4e

Please sign in to comment.