Terraform to deploy Randcast AWS Metrics and Alarms infrastructure.
# deploy us-east-1 resources
cd us-east-1/terraform
terraform plan
terraform apply
# deploy us-east-2 resources
cd us-east-2/terraform
terraform plan
terraform apply
# General
cd terraform
terraform init # download provider plugins to intereact with aws
terraform validate # validate
terraform plan # view the state changes that will occur
terraform apply # provision the resources
terraform destroy # kill previously provisioned resources
(within us-east-1 or us-east-2)
.
└── terraform/
├── cloudwatch.tf
├── lambda-s3-bucket.tf
├── lambda.tf
├── provider.tf
├── sns-topic.tf
└── variables.tf
└── functions/
└── send-cloudwatch-alarms-to-slack/
└── function.py
-
Eth Mainnet (1)
-
OP Mainnet (10)
-
Base Mainnet (8453)
-
Redstone Mainnet (?)
-
Eth Goerli (5)
-
OP Goerli (420)
-
Base Goerli (84531)
-
Lootchain Goerli (9088912)
-
Eth Sepolia (11155111)
-
OP Sepolia (11155420) <- (randcast not yet implemented)
-
Base Sepolia (84532) <- (randcast not yet implemented)
-
Eth Holesky (17000)
-
Redstone Holesky (17001)
-
Taiko Katla Holesky (167008)
Look at cloudwatch.tf, add a metric filter and alarm section for the new network.
- Eth Goerli: "Transaction successful(fulfill_randomness) with chain_id(5)"
- OP Goerli: "Transaction successful(fulfill_randomness) with chain_id(420)"
- Base Goerli: "Transaction successful(fulfill_randomness) with chain_id(84531)"
- Lootchain Goerli: "Transaction successful(fulfill_randomness) with chain_id(9088912)"
- Eth Holesky: "Transaction successful(fulfill_randomness) with chain_id(17000)"
- Redstone Holesky: "Transaction successful(fulfill_randomness) with chain_id(17001)"
- Taiko Katla Holesky: "Transaction successful(fulfill_randomness) with chain_id(167008)"
- Eth Sepolia: "Transaction successful(fulfill_randomness) with chain_id(11155111)"
- OP Sepolia: "Transaction successful(fulfill_randomness) with chain_id(11155420)"
- Base Sepolia: "Transaction successful(fulfill_randomness) with chain_id(84532)"
- Eth Mainnet: "Transaction successful(fulfill_randomness) with chain_id(1)"
- OP Mainnet: "Transaction successful(fulfill_randomness) with chain_id(10)"
- Base Mainnet: "Transaction successful(fulfill_randomness) with chain_id(8453)"
-
terraform/variables.tf: region set here to match folder. This region is used to name global variables:
- IAM Role: sns-logs-${var.region}
- IAM Role: send-cloudwatch-alarms-to-slack-${var.region}
- Lambda S3: lambda-${var.region}-pet-name
-
terraform/cloudwatch.tf: metric filters and alarms set to match regional log groups.
- eth goerli: 0xCA7990A5639560Df0e20aEAD45AD2c0990768a64 (sub #8)
- op goerli: 0x278c8a42b3506724153625e7e233BD5940042F0F (sub #87)
- eth sepolia: 0x98dB27BCa7193dae03dBaA67d16B90B49F2C6722 (sub #112)
Note: The slack_url webhook secret was manually added to SSM Parameter Store encrypted via console, and is referenced by the lambda code like so:
# functions/send-cloudwatch-alarms-to-slack/function.py
ssm = boto3.client("ssm")
parameter = ssm.get_parameter(Name="slack_url", WithDecryption=True)
slack_url = parameter["Parameter"]["Value"]