forked from opensearch-project/opensearch-migrations
-
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.
Merge pull request opensearch-project#1050 from peternied/aws-features
Add a script to determine the AWS resources used
- Loading branch information
Showing
10 changed files
with
96 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ dist | |
.cdk.staging | ||
cdk.out | ||
certs | ||
cdk-synth-output |
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
41 changes: 41 additions & 0 deletions
41
deployment/cdk/opensearch-service-migration/awsFeatureUsage.sh
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
if [ -z "$1" ]; then | ||
echo "Error: contextId is required. Please pass it as the first argument to the script." | ||
echo "Usage: $0 <contextId>" | ||
exit 1 | ||
fi | ||
|
||
contextId="$1" | ||
|
||
output_dir="cdk-synth-output" | ||
rm -rf "$output_dir" | ||
mkdir -p "$output_dir" | ||
|
||
echo "Synthesizing all stacks..." | ||
raw_stacks=$(cdk list --ci --context contextId=$contextId) | ||
|
||
echo "$raw_stacks" | sed -E 's/ *\(.*\)//' | while read -r stack; do | ||
echo "Synthesizing stack: $stack" | ||
cdk synth $stack --ci --context contextId=$contextId > "$output_dir/$stack.yaml" | ||
done | ||
|
||
echo "Finding resource usage from synthesized stacks..." | ||
echo "-----------------------------------" | ||
echo "IAM Policy Actions:" | ||
|
||
grep -h -A 1000 "PolicyDocument:" "$output_dir"/*.yaml | \ | ||
grep -E "Action:" -A 50 | \ | ||
grep -E "^[ \t-]+[a-zA-Z0-9]+:[a-zA-Z0-9\*]+" | \ | ||
grep -vE "^[ \t-]+(aws:|arn:)" | \ | ||
sed -E 's/^[ \t-]+//' | \ | ||
sort -u | ||
|
||
echo "-----------------------------------" | ||
echo "Resources Types:" | ||
|
||
grep -h -E " Type: AWS" "$output_dir"/*.yaml | \ | ||
sed -E 's/^[ \t]*Type: //' | \ | ||
sort -u |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
if [ -z "$1" ]; then | ||
echo "Error: contextId is required. Please pass it as the first argument to the script." | ||
echo "Usage: $0 <contextId>" | ||
exit 1 | ||
fi | ||
|
||
contextId="$1" | ||
|
||
export CDK_CLI_COMMAND=deploy | ||
cdk deploy "*" --c contextId=$contextId --require-approval never --concurrency 5 |
20 changes: 20 additions & 0 deletions
20
deployment/cdk/opensearch-service-migration/lib/cdk-logger.ts
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Logger that prints messages in the CDK ecosystem | ||
*/ | ||
export class CdkLogger { | ||
private constructor() {} | ||
|
||
static info(message: string) { | ||
if (process.env.CDK_CLI_COMMAND === 'deploy') { | ||
console.log(message); | ||
} | ||
} | ||
|
||
static warn(message: string) { | ||
console.log(message); | ||
} | ||
|
||
static error(message: string) { | ||
console.log(message); | ||
} | ||
} |
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
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
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