Skip to content

Commit

Permalink
feat - Upgrade OpenSearch to 1.3 (#13)
Browse files Browse the repository at this point in the history
* opensearch_1_3
  • Loading branch information
prashanttct07 authored Aug 2, 2022
1 parent cbbac5c commit c2f9aa2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ $ source .env/bin/activate

### Bootstrap the CDK

Create the CDK configuration by bootstrapping the CDK.
Create the CDK configuration by bootstrapping the CDK (one-time activity for each region).

```bash
# bootstrap the cdk
Expand Down
13 changes: 2 additions & 11 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,12 @@ source .env/bin/activate
# Load dependency for lambda functions
.env/bin/python -m pip install --target CWMetricsToOpenSearch/ -r CWMetricsToOpenSearch/requirements.txt

# create the key pair
# Set region to deploy the stack
region_default="us-east-1"
echo -e
read -p "Please enter your region to bootstrap the env [$region_default]: " region
read -p "Please enter your region to deploy the stack [$region_default]: " region
region="${region:-$region_default}"
aws configure set default.region $region
aws ec2 create-key-pair --key-name amazon_opensearch_monitoring --query 'KeyMaterial' --output text > amazon_opensearch_monitoring.pem --region $region
# update key_pair permissions
chmod 400 amazon_opensearch_monitoring.pem
# move key_pair to .ssh
mv -f amazon_opensearch_monitoring.pem $HOME/.ssh/amazon_opensearch_monitoring.pem
# start the ssh agent
eval `ssh-agent -s`
# add your key to keychain
ssh-add -k ~/.ssh/amazon_opensearch_monitoring.pem

# Add e-mail for the notification
email_default="[email protected]"
Expand Down
8 changes: 5 additions & 3 deletions opensearch/opensearch_monitor_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ def __init__(self, scope: Construct, id: str, **kwargs) -> None:
es_sec_grp.add_ingress_rule(ec2.Peer.any_ipv4(), ec2.Port.tcp(80))
es_sec_grp.add_ingress_rule(ec2.Peer.any_ipv4(), ec2.Port.tcp(443))

vpc_subnets = ec2.SubnetSelection(
subnet_type=ec2.SubnetType.PUBLIC
)
domain = opensearch.Domain(self, 'opensearch-service-monitor',
version=opensearch.EngineVersion.OPENSEARCH_1_2, # Upgrade when CDK upgrades
version=opensearch.EngineVersion.OPENSEARCH_1_3, # Upgrade when CDK upgrades
domain_name=DOMAIN_NAME,
removal_policy=RemovalPolicy.DESTROY,
capacity=opensearch.CapacityConfig(
Expand All @@ -102,7 +105,7 @@ def __init__(self, scope: Construct, id: str, **kwargs) -> None:
volume_type=ec2.EbsDeviceVolumeType.GP2
),
vpc=vpc,
vpc_subnets=[ec2.SubnetType.PUBLIC],
vpc_subnets=[vpc_subnets],
security_groups=[es_sec_grp],
zone_awareness=opensearch.ZoneAwarenessConfig(
enabled=True,
Expand Down Expand Up @@ -234,7 +237,6 @@ def __init__(self, scope: Construct, id: str, **kwargs) -> None:
vpc=vpc,
machine_image=amzn_linux,
vpc_subnets=sn_public,
key_name=EC2_KEY_NAME,
role=role,
)
instance.connections.allow_from_any_ipv4(ec2.Port.tcp(22), 'SSH')
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
aws-cdk-lib>=2.12.0
aws-cdk-lib>=2.35.0
constructs>=10.0.0
boto3

0 comments on commit c2f9aa2

Please sign in to comment.