START INSTRUCTION FOR TECHNATIVE ENGINEERS
Template for creating a new TerraForm AWS Module. For TechNative Engineers.
Think hard and come up with the shortest descriptive name for your module. Look at competition in the terraform registry.
Your module name should be max. three words seperated by dashes. E.g.
- html-form-action
- new-account-notifier
- budget-alarms
- fix-missing-tags
- Click the template button on the top right...
- Name github project
terraform-aws-[your-module-name]
- Make project private untill ready for publication
- Add a description in the
About
section (top right) - Add tags:
terraform
,terraform-module
,aws
and more tags relevant to your project: e.g.s3
,lambda
,sso
, etc.. - Install
pre-commit
- Develop your module
- Try to use the best practices for TerraForm development and TerraForm AWS Development.
- Set well written title
- Add one or more shields
- Start readme with a short and complete as possible module description. This is the part where you sell your module.
- Complete README with well written documentation. Try to think as a someone with three months of Terraform experience.
- Check if pre-commit correctly generates the standard Terraform documentation.
If your module is in a state that it could be useful for others and ready for publication, you can publish a first version.
- Create a Github Release
- Publish in the TerraForm Registry under the Technative Namespace (the GitHub Repo must be in the TechNative Organization)
END INSTRUCTION FOR TECHNATIVE ENGINEERS
This module allows you to start and stop instances on a defined schedule. The schedules are stored in a DynamoDB table along with their time periods.
A named schedule that defines when instances tagged with that schedule should run. The schedule name is used as the value for the InstanceScheduler tag on any instance you want to manage via this module.
Each schedule has one or more periods. A period defines a set of rules about which days, what timezone, what start time, and what end time the schedule applies.
Each period includes the following:
weekdays - One or more days of the week when the period is active.You can use multiple days.(e.g. mon, tue, fri)
Valid abbreviations: mon, tue, wed, thu, fri, sat, sun.
timezone - The timezone for interpreting begintime and endtime.UTC is the default timezone.
begintime- The time of day when instances should start (in 24-hour format, e.g. 09:00).
endtime - The time of day when instances should stop (in 24-hour format, e.g. 17:00).
Each schedule must have at least one period.
You can have multiple periods within a schedule (for instance, one for weekdays 9-17, another for weekends).
Times are in 24-hour format.
Days must use consistent abbreviations (e.g. mon, tue, etc.).
Run pre-commit install
to install any guardrails implemented using pre-commit.
See pre-commit installation on how to install pre-commit.
...
To use this module ...
module "scheduler"{
source = "[email protected]:wearetechnative/terraform-aws-lambda.git"
bucket_name = "instancescheduler-bucket-example"
dynamodb_table_name = "instance_scheduler"
kms_key_arn = *******
lambda_role_name = "scheduler_role"
periods = [
{
"name": "7am-to-8pm",
"days": ["mon", "tue", "wed", "thu", "fri"],
"begintime": "7:00",
"endtime": "20:00",
"timezone": "Europe/Amsterdam"
},
{
"name": "8am-to-7pm",
"days": ["mon", "tue", "wed", "thu", "fri"],
"begintime": "8:00",
"endtime": "19:00",
"timezone": "Europe/Amsterdam"
}
]
schedules = [
{
"name": "mon-fri-7am-to-8pm",
"period": ["7am-to-8pm"]
},
{
"name": "mon-fri-8am-to-7pm",
"period": ["8am-to-7pm"]
}
]
sqs_arn = ********
}
No requirements.
Name | Version |
---|---|
aws | n/a |
Name | Source | Version |
---|---|---|
dynamodb_instance_scheduler | github.com/wearetechnative/terraform-aws-module-dynamodb.git | n/a |
ec2_lambda | github.com/wearetechnative/terraform-aws-lambda.git | n/a |
iam_role_lambda_instance_scheduler | github.com/wearetechnative/terraform-aws-iam-role.git | n/a |
iam_role_webpage_scheduler | github.com/wearetechnative/terraform-aws-iam-role.git | n/a |
lambda_start_stop_instances | github.com/wearetechnative/terraform-aws-lambda.git | n/a |
sqs_dlq | ../01_sqs_dlq | n/a |
Name | Type |
---|---|
aws_apigatewayv2_api.my_api | resource |
aws_apigatewayv2_integration.int | resource |
aws_apigatewayv2_route.my_route | resource |
aws_apigatewayv2_stage.my_api_stg | resource |
aws_cloudwatch_event_rule.rule | resource |
aws_cloudwatch_event_target.lambda_trigger | resource |
aws_dynamodb_table_item.period | resource |
aws_dynamodb_table_item.schedules | resource |
aws_kms_grant.a | resource |
aws_lambda_permission.allow_API | resource |
aws_lambda_permission.allow_API_1 | resource |
aws_lambda_permission.allow_API_2 | resource |
aws_lambda_permission.allow_API_3 | resource |
aws_lambda_permission.allow_eventbridge | resource |
aws_s3_bucket.webpage_bucket | resource |
aws_s3_bucket_object.object | resource |
aws_s3_bucket_object.object2 | resource |
aws_s3_bucket_object.object3 | resource |
aws_s3_bucket_website_configuration.website_conf | resource |
aws_iam_policy_document.instance_scheduler | data source |
aws_iam_policy_document.launch_ec2 | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
bucket_name | n/a | string |
n/a | yes |
dynamodb_table_name | n/a | string |
n/a | yes |
kms_key_arn | n/a | string |
n/a | yes |
lambda_role_name | name for lambda role which will be created by this module | string |
n/a | yes |
periods | n/a | list(object({ |
n/a | yes |
schedules | n/a | list(object({ |
n/a | yes |
sqs_arn | n/a | string |
n/a | yes |
No outputs.