-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update the cdk for mongodb atlas cluster , created a new folder for t…
…he lambda file, updated the readem
- Loading branch information
1 parent
71a9115
commit e88e53c
Showing
57 changed files
with
4,198 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,57 @@ | ||
#!/usr/bin/env python3 | ||
import os | ||
|
||
import aws_cdk as cdk | ||
|
||
from aws_mongodb_sample.aws_mongo_db_create import AwsMongodbAtlasCreateStack | ||
from aws_mongodb_sample.aws_mongodb_sample_stack import AwsMongodbSampleStack | ||
from aws_mongodb_sample.aws_amplify_stack import amplifystack | ||
from global_args import GlobalArgs | ||
import boto3 | ||
import json | ||
import base64 | ||
|
||
def get_secret(secret_name): | ||
session = boto3.session.Session() | ||
client = session.client( | ||
service_name='secretsmanager', | ||
region_name = GlobalArgs.AWS_REGION ) | ||
|
||
app = cdk.App() | ||
get_secret_value_response = client.get_secret_value( SecretId=secret_name) | ||
|
||
if 'SecretString' in get_secret_value_response: | ||
secret = get_secret_value_response['SecretString'] | ||
else: | ||
secret = base64.b64decode(get_secret_value_response['SecretBinary']) | ||
|
||
AtlasClusterStack = AwsMongodbAtlasCreateStack(app, "AwsMongodbAtlasCreateStack", | ||
env=cdk.Environment(account=os.getenv('CDK_DEFAULT_ACCOUNT'), region=os.getenv('CDK_DEFAULT_REGION')), | ||
return json.loads(secret) | ||
|
||
# For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html | ||
) | ||
secret_name = GlobalArgs.SECRET_NAME | ||
secrets = get_secret(secret_name) | ||
|
||
atlasuri = AtlasClusterStack.Atlas_URI | ||
aws_account_id = secrets["AWSACCOUNTID"] | ||
aws_region = GlobalArgs.AWS_REGION | ||
|
||
|
||
AwsMongodbSampleStack(app, "AwsMongodbSampleStack", | ||
app = cdk.App() | ||
|
||
# If you don't specify 'env', this stack will be environment-agnostic. | ||
# Account/Region-dependent features and context lookups will not work, | ||
# but a single synthesized template can be deployed anywhere. | ||
|
||
# Uncomment the next line to specialize this stack for the AWS Account | ||
# and Region that are implied by the current CLI configuration. | ||
|
||
#env=cdk.Environment(account=os.getenv('CDK_DEFAULT_ACCOUNT'), region=os.getenv('CDK_DEFAULT_REGION')), | ||
#atlas_uri=atlasuri, | ||
|
||
env=cdk.Environment(account=os.getenv('CDK_DEFAULT_ACCOUNT'), | ||
region=os.getenv('CDK_DEFAULT_REGION')), | ||
atlas_uri = atlasuri, | ||
AtlasClusterStack = AwsMongodbAtlasCreateStack(app, "AwsMongodbAtlasCreateStack", | ||
env=cdk.Environment(account=aws_account_id, region=aws_region), | ||
) | ||
|
||
|
||
# Uncomment the next line if you know exactly what Account and Region you | ||
# want to deploy the stack to. */ | ||
atlasuri = AtlasClusterStack.Atlas_URI | ||
|
||
#env=cdk.Environment(account='123456789012', region='us-east-1'), | ||
|
||
# For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html | ||
AwsMongodbSampleStack(app, "AwsMongodbSampleStack", | ||
env=cdk.Environment(account=aws_account_id, region=aws_region), | ||
atlas_uri = atlasuri, | ||
) | ||
|
||
# amplifystack(app, "amplifystack", | ||
# env=cdk.Environment(account=aws_account_id, region=aws_region) | ||
# ) | ||
|
||
|
||
|
||
app.synth() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.