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
module "noiselesstech_cron" { | |
source = "hendrixroa/cron-ecs-task/aws" | |
app = "noiselesstech" | |
# Compute resources | |
cpu_unit = 1024 | |
memory = 2048 | |
# Cron |
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
resource "aws_ecs_cluster" "main" { | |
name = var.app_name | |
capacity_providers = ["FARGATE"] | |
} |
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
resource "aws_cloudwatch_event_rule" "cron_five_minutes" { | |
name = "cron_rate_5" | |
description = "Schedule trigger for run every 5 minutes" | |
schedule_expression = "rate(5 minutes)" | |
is_enabled = true | |
} |
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
resource "aws_security_group" "sample" { | |
name = "sample" | |
description = "security group" | |
vpc_id = module.vpc.vpc_id | |
ingress { | |
from_port = 0 | |
to_port = 0 | |
protocol = "-1" | |
cidr_blocks = ["0.0.0.0/0"] |
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
package com.blog.noiselesstech; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.springframework.boot.CommandLineRunner; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import java.util.concurrent.TimeUnit; |
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
module "vpc" { | |
source = "terraform-aws-modules/vpc/aws" | |
name = "NoiselessVPC" | |
cidr = "10.0.0.0/16" | |
azs = ["${var.region}a", "${var.region}b", "${var.region}c"] | |
private_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"] | |
public_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"] | |
} |
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
resource "aws_cloudwatch_event_target" "main" { | |
target_id = "${var.app}-target" | |
arn = var.ecs_cluster | |
rule = var.event_rule | |
role_arn = var.ecs_event_role | |
ecs_target { | |
task_count = 1 | |
task_definition_arn = aws_ecs_task_definition.main.arn | |
launch_type = "FARGATE" |
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
resource "aws_iam_role" "ecs_events" { | |
name = "ecs_events" | |
assume_role_policy = <<DOC | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "", | |
"Effect": "Allow", |
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
resource "aws_iam_role" "ecs_task_execution" { | |
name = "noiselesstech_task_execution_role" | |
assume_role_policy = <<DOC | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "", | |
"Effect": "Allow", | |
"Principal": { |
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
resource "aws_ecs_task_definition" "main" { | |
family = "${var.app}-service" | |
requires_compatibilities = ["FARGATE"] | |
network_mode = "awsvpc" | |
execution_role_arn = var.execution_role_arn | |
cpu = var.cpu_unit | |
memory = var.memory | |
container_definitions = data.template_file.main.rendered | |
} |
NewerOlder