-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
1,761 additions
and
327 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
secrets=$(aws secretsmanager get-secret-value --secret-id api-secrets --region $AWS_REGION | jq -r '.SecretString') | ||
|
||
IFS=$'\n' read -r -d '' -a keys <<< "$(echo $secrets | jq -r 'keys[]')" | ||
|
||
touch .env | ||
chown webapp:webapp .env | ||
for key in "${keys[@]}"; do | ||
value=$(echo $secrets | jq -r ".\"$key\"") | ||
printf "%s=%s\n" "$key" "$value" | ||
done > .env |
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 @@ | ||
#!/bin/sh | ||
# In case we merge two env secrets into a flattened one in the same region | ||
# secrets=$(aws secretsmanager get-secret-value --secret-id api-secrets --region $AWS_REGION | jq -r '.SecretString') | ||
|
||
# IFS=$'\n' read -r -d '' -a key_value_pairs <<< "$(echo $secrets | jq -r --arg prefix "$PREFIX" 'to_entries[] | select((.key | ascii_upcase) | startswith(($prefix+"_") | ascii_upcase)) | ((.key | sub(($prefix+"_"); ""; "i")) + "=" + .value)')" | ||
|
||
# for pair in "${key_value_pairs[@]}"; do | ||
# echo "$pair" | ||
# done | ||
|
||
secrets=$(aws secretsmanager get-secret-value --secret-id api-secrets --region $AWS_REGION | jq -r '.SecretString') | ||
|
||
IFS=$'\n' read -r -d '' -a keys <<< "$(echo $secrets | jq -r 'keys[]')" | ||
|
||
touch /var/app/staging/.env | ||
chown webapp:webapp /var/app/staging/.env | ||
for key in "${keys[@]}"; do | ||
value=$(echo $secrets | jq -r ".\"$key\"") | ||
printf "%s=%s\n" "$key" "$value" | ||
done >> /var/app/staging/.env |
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,11 @@ | ||
#!/bin/sh | ||
secrets=$(aws secretsmanager get-secret-value --secret-id api-secrets --region $AWS_REGION | jq -r '.SecretString') | ||
|
||
IFS=$'\n' read -r -d '' -a keys <<< "$(echo $secrets | jq -r 'keys[]')" | ||
|
||
touch .env | ||
chown webapp:webapp .env | ||
for key in "${keys[@]}"; do | ||
value=$(echo $secrets | jq -r ".\"$key\"") | ||
printf "%s=%s\n" "$key" "$value" | ||
done > .env |
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 @@ | ||
#!/bin/sh | ||
# In case we merge two env secrets into a flattened one in the same region | ||
# secrets=$(aws secretsmanager get-secret-value --secret-id api-secrets --region $AWS_REGION | jq -r '.SecretString') | ||
|
||
# IFS=$'\n' read -r -d '' -a key_value_pairs <<< "$(echo $secrets | jq -r --arg prefix "$PREFIX" 'to_entries[] | select((.key | ascii_upcase) | startswith(($prefix+"_") | ascii_upcase)) | ((.key | sub(($prefix+"_"); ""; "i")) + "=" + .value)')" | ||
|
||
# for pair in "${key_value_pairs[@]}"; do | ||
# echo "$pair" | ||
# done | ||
|
||
secrets=$(aws secretsmanager get-secret-value --secret-id api-secrets --region $AWS_REGION | jq -r '.SecretString') | ||
|
||
IFS=$'\n' read -r -d '' -a keys <<< "$(echo $secrets | jq -r 'keys[]')" | ||
|
||
touch /var/app/staging/.env | ||
chown webapp:webapp /var/app/staging/.env | ||
for key in "${keys[@]}"; do | ||
value=$(echo $secrets | jq -r ".\"$key\"") | ||
printf "%s=%s\n" "$key" "$value" | ||
done >> /var/app/staging/.env |
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { | ||
CloudWatchClient, | ||
CloudWatchClientConfig, | ||
MetricDatum, | ||
PutMetricDataCommand, | ||
} from '@aws-sdk/client-cloudwatch'; | ||
import { env } from '../../app/env'; | ||
|
||
export interface NotificationsCloudwatchMetric { | ||
merticData: MetricDatum[]; | ||
nameSpace: string; | ||
} | ||
|
||
export class CloudwatchCronDurationMetricsPublisher { | ||
protected environment: string; | ||
protected configuration?: CloudWatchClientConfig; | ||
private client: CloudWatchClient; | ||
public namespace: string; | ||
|
||
constructor( | ||
namespace: string = 'default', | ||
environment: string = env.DEPLOYMENT_ENV, | ||
configuration?: CloudWatchClientConfig, | ||
) { | ||
this.namespace = namespace; | ||
this.environment = environment; | ||
this.client = new CloudWatchClient({ region: env.AWS_REGION, ...configuration }); | ||
} | ||
|
||
public async publish(metricName: string, count?: number): Promise<void> { | ||
const [major, minor, patch] = process.versions.node.split('.').map(Number); | ||
try { | ||
const command = new PutMetricDataCommand({ | ||
MetricData: [ | ||
{ | ||
MetricName: metricName, | ||
Dimensions: [ | ||
{ | ||
Name: 'Environment', | ||
Value: this.environment, | ||
}, | ||
{ | ||
Name: 'NodeVersion', | ||
Value: major.toString(), | ||
}, | ||
], | ||
Unit: 'None', | ||
Timestamp: new Date(), | ||
Value: count ? count : 1, | ||
}, | ||
], | ||
Namespace: this.namespace, | ||
}); | ||
|
||
await this.client.send(command); | ||
} catch (err) { | ||
// Sentry.captureException(`Failed to publish "${metricName}" in "${this.environment}: ${err}`); | ||
console.log(`Failed to publish "${metricName}" in "${this.environment}: ${err}`); | ||
} | ||
} | ||
} | ||
|
||
export const cronsDurationMetricPublisher = new CloudwatchCronDurationMetricsPublisher('backendCronsDuration'); |
Oops, something went wrong.