Terraform module to quickly spin up my chat bots.
To use this module, use the following as the source: github.com/kn-lim/chattingway-terraform
Make sure to build the binaries, name it bootstrap
and compress them into .zip files in order for Terraform to create the resources. This will need to be done only when first applying the module.
terraform {
required_version = ">= 1.10"
}
locals {
name = "slackingway-bot"
account_id = ""
debug = "false"
slack_signing_secret = ""
slack_oauth_token = ""
slack_history_channel_id = ""
slack_output_channel_id = ""
admin_role_users = ""
# These non-empty .zip files are needed only when creating resources.
# Run the build commands and zip the binary files.
# The .zip file an be deleted/moved afterwards.
endpoint_filename = "/path/to/endpoint.zip"
task_filename = "/path/to/task.zip"
}
module "slackingway-bot" {
# https://github.com/kn-lim/chattingway-terraform
source = "github.com/kn-lim/chattingway-terraform?ref=v1.1.2"
# Required
account_id = local.account_id
endpoint_filename = local.endpoint_filename
task_filename = local.task_filename
endpoint_environment_variables = {
ADMIN_ROLE_USERS = local.admin_role_users
DEBUG = local.debug
SLACK_HISTORY_CHANNEL_ID = local.slack_history_channel_id
SLACK_OAUTH_TOKEN = local.slack_oauth_token
SLACK_OUTPUT_CHANNEL_ID = local.slack_output_channel_id
SLACK_SIGNING_SECRET = local.slack_signing_secret
TASK_FUNCTION_NAME = "${local.name}-task"
}
task_environment_variables = {
DEBUG = local.debug
SLACK_HISTORY_CHANNEL_ID = local.slack_history_channel_id
SLACK_OAUTH_TOKEN = local.slack_oauth_token
SLACK_OUTPUT_CHANNEL_ID = local.slack_output_channel_id
SLACK_SIGNING_SECRET = local.slack_signing_secret
}
# Optional
# name = local.name
log_format = "Text"
# region = "us-west-2"
# retention_in_days = 3
# runtime = "provided.al2023"
# endpoint_timeout = 3
# task_timeout = 300
# ec2_instance_arns = []
# tags = {
# App = local.name
# }
}
output "api_endpoint" {
description = "The endpoint for the API Gateway"
value = module.slackingway-bot.api_endpoint
}
terraform {
required_version = ">= 1.10"
}
locals {
name = "dreamingway-bot"
account_id = ""
debug = "false"
discord_api_version = "10"
discord_bot_application_id = ""
discord_bot_public_key = ""
discord_bot_token = ""
# These non-empty .zip files are needed only when creating resources.
# Run the build commands and zip the binary files.
# The .zip file an be deleted/moved afterwards.
endpoint_filename = "/path/to/endpoint.zip"
task_filename = "/path/to/task.zip"
}
module "dreamingway-bot" {
# https://github.com/kn-lim/chattingway-terraform
source = "github.com/kn-lim/chattingway-terraform?ref=v1.1.2"
# Required
account_id = local.account_id
endpoint_filename = local.endpoint_filename
task_filename = local.task_filename
endpoint_environment_variables = {
ADMIN_ROLE_USERS = local.admin_role_users
DEBUG = local.debug
DISCORD_BOT_APPLICATION_ID = local.discord_bot_application_id
DISCORD_BOT_PUBLIC_KEY = local.discord_bot_public_key
DISCORD_BOT_TOKEN = local.discord_bot_token
TASK_FUNCTION_NAME = "${local.name}-task"
}
task_environment_variables = {
DEBUG = local.debug
DISCORD_API_VERSION = local.discord_api_version
DISCORD_BOT_TOKEN = local.discord_bot_token
}
# Optional
# name = local.name
# log_format = "JSON"
# region = "us-west-2"
# retention_in_days = 3
# runtime = "provided.al2023"
# endpoint_timeout = 3
# task_timeout = 300
# ec2_instance_arns = []
# tags = {
# App = local.name
# }
}
output "api_endpoint" {
description = "The endpoint for the API Gateway"
value = module.dreamingway-bot.api_endpoint
}
Name | Version |
---|---|
aws | ~> 5.0 |
Name | Version |
---|---|
terraform | >= 1.10 |
aws | ~> 5.0 |
Name | Type |
---|---|
aws_api_gateway_deployment.this | resource |
aws_api_gateway_integration.this | resource |
aws_api_gateway_method.this | resource |
aws_api_gateway_resource.this | resource |
aws_api_gateway_rest_api.this | resource |
aws_api_gateway_stage.this | resource |
aws_cloudwatch_log_group.endpoint | resource |
aws_cloudwatch_log_group.task | resource |
aws_iam_policy.this | resource |
aws_iam_role.endpoint | resource |
aws_iam_role.task | resource |
aws_iam_role_policy.invoke | resource |
aws_iam_role_policy.manage_ec2 | resource |
aws_iam_role_policy_attachment.lambda_logs_endpoint | resource |
aws_iam_role_policy_attachment.lambda_logs_task | resource |
aws_lambda_function.endpoint | resource |
aws_lambda_function.task | resource |
aws_lambda_permission.api_gateway | resource |
aws_iam_policy_document.assume_role | data source |
aws_iam_policy_document.lambda_logging | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
account_id | The AWS account ID | string |
n/a | yes |
ec2_instance_arns | A list of EC2 instance ARNs to manage | list(string) |
[] |
no |
endpoint_environment_variables | A map of environment variables to apply to the Endpoint Lambda function | map(string) |
n/a | yes |
endpoint_filename | The filename to upload to the Endpoint Lambda function | string |
n/a | yes |
endpoint_timeout | The timeout for the Endpoint Lambda function | number |
3 |
no |
log_format | The log format for the CloudWatch logs | string |
"JSON" |
no |
name | The name of the resources | string |
"chattingway" |
no |
region | The region in which the resources will be created | string |
"us-west-2" |
no |
retention_in_days | The number of days to retain logs in CloudWatch | number |
3 |
no |
runtime | The runtime for the Lambda functions | string |
"provided.al2023" |
no |
tags | A map of tags to apply to the resources | map(string) |
{ |
no |
task_environment_variables | A map of environment variables to apply to the Task Lambda function | map(string) |
n/a | yes |
task_filename | The filename to upload to the Task Lambda function | string |
n/a | yes |
task_timeout | The timeout for the Task Lambda function | number |
300 |
no |
Name | Description |
---|---|
api_endpoint | The endpoint for the API Gateway |
endpoint_function_arn | The ARN of the Endpoint Lambda function |
task_function_arn | The ARN of the Task Lambda function |