File tree Expand file tree Collapse file tree 4 files changed +118
-0
lines changed
Expand file tree Collapse file tree 4 files changed +118
-0
lines changed Original file line number Diff line number Diff line change 1+ resource "aws_iam_role" "LambdaRkoRouter" {
2+ name = " LambdaRkoRouter"
3+ description = " rko-router//tf/lambda.tf"
4+ assume_role_policy = data. aws_iam_policy_document . LambdaRkoRouter-trust . json
5+ }
6+
7+ data "aws_iam_policy_document" "LambdaRkoRouter-trust" {
8+ statement {
9+ effect = " Allow"
10+ actions = [" sts:AssumeRole" ]
11+ principals {
12+ type = " Service"
13+ identifiers = [
14+ " lambda.amazonaws.com"
15+ ]
16+ }
17+ }
18+ }
19+
20+ resource "aws_iam_role_policy_attachment" "lambda-AWSLambdaBasicExecutionRole" {
21+ role = aws_iam_role. LambdaRkoRouter . name
22+ policy_arn = " arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
23+ }
24+
25+
Original file line number Diff line number Diff line change 1+ resource "aws_iam_role" "SchedulerRkoRouter" {
2+ name = " SchedulerRkoRouter"
3+ description = " rko-router//tf/iam_SchedulerRkoRouter.tf"
4+ assume_role_policy = data. aws_iam_policy_document . SchedulerRkoRouter-trust . json
5+ max_session_duration = 3600
6+ }
7+
8+ data "aws_iam_policy_document" "SchedulerRkoRouter-trust" {
9+ statement {
10+ effect = " Allow"
11+ actions = [" sts:AssumeRole" ]
12+ principals {
13+ type = " Service"
14+ identifiers = [
15+ " scheduler.amazonaws.com" ,
16+ ]
17+ }
18+ }
19+ }
20+
21+ resource "aws_iam_role_policy" "SchedulerRkoRouter" {
22+ role = aws_iam_role. SchedulerRkoRouter . name
23+ policy = data. aws_iam_policy_document . SchedulerRkoRouter . json
24+ }
25+
26+ data "aws_iam_policy_document" "SchedulerRkoRouter" {
27+ statement {
28+ effect = " Allow"
29+ actions = [
30+ " lambda:InvokeFunction" ,
31+ ]
32+ resources = [
33+ aws_lambda_function . rko-router . arn ,
34+ ]
35+ }
36+ }
Original file line number Diff line number Diff line change 1+ resource "aws_lambda_function" "rko-router" {
2+ function_name = " rko-router"
3+
4+ package_type = " Image"
5+ image_uri = " ${ aws_ecr_repository . rko-router . repository_url } :3285c10bdd196708e97523c116baeba981b8b8a7"
6+ architectures = [" x86_64" ]
7+
8+ role = aws_iam_role. LambdaRkoRouter . arn
9+
10+ memory_size = 256
11+ timeout = 30
12+
13+ environment {
14+ variables = {
15+ AWS_LWA_INVOKE_MODE = " response_stream"
16+ NGINX_ENTRYPOINT_QUIET_LOGS = " 1"
17+
18+ JUMP_HOST = " *.lambda-url.us-west-2.on.aws"
19+ }
20+ }
21+
22+ tags = {
23+ Name = " rko-router"
24+ }
25+
26+ # lifecycle {
27+ # ignore_changes = [
28+ # image_uri,
29+ # ]
30+ # }
31+ }
32+
33+ resource "aws_lambda_function_url" "rko-router" {
34+ function_name = aws_lambda_function. rko-router . function_name
35+ authorization_type = " NONE"
36+ invoke_mode = " RESPONSE_STREAM"
37+ }
38+
39+ output "function_url" {
40+ value = aws_lambda_function_url. rko-router . function_url
41+ }
Original file line number Diff line number Diff line change 1+ resource "aws_scheduler_schedule" "rko-router-wakeup" {
2+ name = " rko-router-wakeup"
3+
4+ flexible_time_window {
5+ mode = " FLEXIBLE"
6+ maximum_window_in_minutes = 90
7+ }
8+
9+ schedule_expression = " rate(12 hours)"
10+
11+ target {
12+ arn = aws_lambda_function. rko-router . arn
13+ role_arn = aws_iam_role. SchedulerRkoRouter . arn
14+ input = jsonencode ({ action = " wake-up" })
15+ }
16+ }
You can’t perform that action at this time.
0 commit comments