Skip to content

Commit cf09ae2

Browse files
committed
Merge branch 'main' into bsc
2 parents 9088715 + 3d5c745 commit cf09ae2

38 files changed

+3002
-0
lines changed

lib/stacks/README.md

Lines changed: 262 additions & 0 deletions
Large diffs are not rendered by default.

lib/stacks/app.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env node
2+
import 'dotenv/config'
3+
import "source-map-support/register";
4+
import * as cdk from "aws-cdk-lib";
5+
import * as nag from "cdk-nag";
6+
import * as config from "./lib/config/stacksConfig";
7+
8+
import { StacksSingleNodeStack } from "./lib/single-node-stack";
9+
import { StacksCommonStack } from "./lib/common-stack";
10+
import { StacksHANodesStack } from './lib/ha-nodes-stack';
11+
12+
const app = new cdk.App();
13+
cdk.Tags.of(app).add("Project", "AWSStacks");
14+
15+
new StacksCommonStack(app, "stacks-common", {
16+
stackName: `stacks-nodes-common`,
17+
env: { account: config.baseConfig.accountId, region: config.baseConfig.region },
18+
});
19+
20+
new StacksSingleNodeStack(app, "stacks-single-node", {
21+
stackName: `stacks-single-node-${config.baseNodeConfig.stacksNodeConfiguration}`,
22+
env: { account: config.baseConfig.accountId, region: config.baseConfig.region },
23+
...config.baseNodeConfig
24+
});
25+
26+
new StacksHANodesStack(app, "stacks-ha-nodes", {
27+
stackName: `stacks-ha-nodes-${config.baseNodeConfig.stacksNodeConfiguration}`,
28+
env: { account: config.baseConfig.accountId, region: config.baseConfig.region },
29+
...config.baseNodeConfig,
30+
...config.haNodeConfig
31+
});
32+
33+
// Security Check
34+
cdk.Aspects.of(app).add(
35+
new nag.AwsSolutionsChecks({
36+
verbose: false,
37+
reports: true,
38+
logIgnores: false,
39+
})
40+
);

lib/stacks/cdk.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"app": "npx ts-node --prefer-ts-exts app.ts",
3+
"watch": {
4+
"include": [
5+
"**"
6+
],
7+
"exclude": [
8+
"README.md",
9+
"cdk*.json",
10+
"**/*.d.ts",
11+
"**/*.js",
12+
"tsconfig.json",
13+
"package*.json",
14+
"yarn.lock",
15+
"node_modules",
16+
"test"
17+
]
18+
},
19+
"context": {
20+
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
21+
"@aws-cdk/core:checkSecretUsage": true,
22+
"@aws-cdk/core:target-partitions": [
23+
"aws",
24+
"aws-cn"
25+
],
26+
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
27+
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
28+
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
29+
"@aws-cdk/aws-iam:minimizePolicies": true,
30+
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
31+
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
32+
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
33+
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
34+
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
35+
"@aws-cdk/core:enablePartitionLiterals": true,
36+
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
37+
"@aws-cdk/aws-iam:standardizedServicePrincipals": true,
38+
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
39+
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
40+
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
41+
"@aws-cdk/aws-route53-patters:useCertificate": true,
42+
"@aws-cdk/customresources:installLatestAwsSdkDefault": false
43+
}
44+
}
138 KB
Loading
85.6 KB
Loading

lib/stacks/jest.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
testEnvironment: 'node',
3+
roots: ['<rootDir>/test'],
4+
testMatch: ['**/*.test.ts'],
5+
transform: {
6+
'^.+\\.tsx?$': 'ts-jest'
7+
},
8+
};
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
3+
# shellcheck source=/dev/null
4+
source /etc/environment
5+
6+
# Download
7+
STACKS_REPO="stacks-core"
8+
STACKS_ORG="stacks-network"
9+
START_DIR=$PWD
10+
11+
# Install build dependencies.
12+
sudo yum update
13+
sudo yum -y install clang llvm git
14+
15+
mkdir -p src && cd src || return
16+
17+
if [ -z "$HOME" ]; then
18+
# Set $HOME to /root. $HOME isn't set to be /root when this
19+
# script first runs on the host.
20+
export HOME="/root"
21+
echo "HOME is not set. Setting it to /root."
22+
fi
23+
24+
# Install Rust.
25+
echo "Install rustc, cargo and rustfmt."
26+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
27+
28+
# shellcheck source=/dev/null
29+
source "$HOME/.cargo/env"
30+
rustup component add rustfmt
31+
32+
echo "Verifying we use the latest stable version of Rust"
33+
rustup update
34+
35+
RUST_STABLE_VERSION=$(rustc --version | awk '{print $2}')
36+
export RUST_STABLE_VERSION
37+
38+
# Get tag for the latest version.
39+
echo "Getting the source for stable version $STACKS_VERSION"
40+
if [ "$STACKS_VERSION" = "latest" ]; then
41+
echo "Aquiring tag for latest stable release."
42+
VERSION_TAG=$(curl -sL https://api.github.com/repos/$STACKS_ORG/$STACKS_REPO/releases/latest | jq -r .tag_name)
43+
else
44+
VERSION_TAG=$STACKS_VERSION
45+
fi
46+
47+
echo "Fetching stacks latest code from stacks release $VERSION_TAG"
48+
wget "https://github.com/$STACKS_ORG/$STACKS_REPO/archive/refs/tags/$VERSION_TAG.tar.gz"
49+
tar -xzvf "$VERSION_TAG.tar.gz"
50+
51+
SOURCE_DIR="$PWD/$STACKS_REPO-$VERSION_TAG"
52+
53+
# Build relevant source code
54+
cd "$SOURCE_DIR" || return
55+
cargo build --features monitoring_prom,slog_json --release --workspace
56+
57+
sudo mkdir -p "$START_DIR/bin"
58+
find target/release/ -maxdepth 1 -perm /a+x ! -type d -exec cp {} "$START_DIR/bin/" \;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[cfn-auto-reloader-hook]
2+
triggers=post.update
3+
path=Resources.WebServerHost.Metadata.AWS::CloudFormation::Init
4+
action=/opt/aws/bin/cfn-init -v --stack "$STACK_ID" --resource WebServerHost --region "$AWS_REGION"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[main]
2+
stack="$STACK_ID"
3+
region="$AWS_REGION"
4+
# The interval used to check for changes to the resource metadata in minutes. Default is 15
5+
interval=2
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[Unit]
2+
Description=cfn-hup daemon
3+
[Service]
4+
Type=simple
5+
ExecStart=/usr/bin/cfn-hup
6+
Restart=always
7+
[Install]
8+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)