-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathendpoint_services_down.sh
More file actions
executable file
·33 lines (27 loc) · 1.04 KB
/
endpoint_services_down.sh
File metadata and controls
executable file
·33 lines (27 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash
# this script uses the awscli to destroy VPC endpoints with specific tags.
# simply specify your profile, region, and tags, and test with --dry-run flag.
# if tests return "Request would have succeeded, but DryRun flag is set", then
# simply comment out the --dry-run flag to actually perform the operation, and destroy the endpoints.
# Note: upon successfully deleting endpoints the CLI will return "Unsuccessful", which appears to be a
# bug, as performing this operation DOES delete the endpoint(s).
# specify AWS profile:
PROFILE="your_aws_profile"
# specify region:
REGION="your_aws_region"
# get VPC endpoints:
ENDPOINTIDS=$(aws ec2 describe-vpc-endpoints \
--query 'VpcEndpoints[*].[VpcEndpointId]' \
--filters Name=tag:your_tag1,Values=your_tag_value1 \
--output text \
--region $REGION \
--profile $PROFILE
)
echo "the following endpoints will be deleted: $ENDPOINTIDS"
# delete endpoint(s)
aws ec2 delete-vpc-endpoints \
--vpc-endpoint-ids $ENDPOINTIDS \
--region $REGION \
--profile $PROFILE \
--dry-run
exit