Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Am I live
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
shore
Am I live
Commits
ab6d849a
Commit
ab6d849a
authored
4 years ago
by
nimrod
Browse files
Options
Downloads
Patches
Plain Diff
Schedule per function.
There's a limit of 5 targets per rule. So rule per function it is.
parent
4a085ae4
No related branches found
No related tags found
No related merge requests found
Pipeline
#1316
passed
4 years ago
Stage: test
Stage: build
Stage: plan
Stage: apply
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
functions.tf
+1
-1
1 addition, 1 deletion
functions.tf
triggers.tf
+12
-11
12 additions, 11 deletions
triggers.tf
with
13 additions
and
12 deletions
functions.tf
+
1
−
1
View file @
ab6d849a
...
@@ -185,7 +185,7 @@ resource "aws_lambda_permission" "cloudwatch" {
...
@@ -185,7 +185,7 @@ resource "aws_lambda_permission" "cloudwatch" {
statement_id
=
"AllowExecutionFromCloudWatch"
statement_id
=
"AllowExecutionFromCloudWatch"
action
=
"lambda:InvokeFunction"
action
=
"lambda:InvokeFunction"
principal
=
"events.amazonaws.com"
principal
=
"events.amazonaws.com"
source_arn
=
local
.
cloudwatch_rule_arn
source_arn
=
local
.
cloudwatch_rule_arn
s
[
count
.
index
]
function_name
=
local
.
function_names
[
count
.
index
]
function_name
=
local
.
function_names
[
count
.
index
]
qualifier
=
local
.
function_alias_names
[
count
.
index
]
qualifier
=
local
.
function_alias_names
[
count
.
index
]
}
}
This diff is collapsed.
Click to expand it.
triggers.tf
+
12
−
11
View file @
ab6d849a
...
@@ -10,31 +10,32 @@ output "rate" {
...
@@ -10,31 +10,32 @@ output "rate" {
}
}
resource
"aws_cloudwatch_event_rule"
"schedule"
{
resource
"aws_cloudwatch_event_rule"
"schedule"
{
name
=
local
.
Name
count
=
length
(
local
.
function_names
)
description
=
"Schedule to trigger
${
local
.
module
}
functions in
${
local
.
env
}
."
name
=
local
.
function_names
[
count
.
index
]
description
=
"Schedule to trigger
${
local
.
function_names
[
count
.
index
]}
functions in
${
local
.
env
}
."
schedule_expression
=
"rate(
${
var
.
rate
}
minutes)"
schedule_expression
=
"rate(
${
var
.
rate
}
minutes)"
tags
=
local
.
common_tags
tags
=
local
.
common_tags
}
}
locals
{
locals
{
cloudwatch_rule_arn
=
aws_cloudwatch_event_rule
.
schedule
.
arn
cloudwatch_rule_arn
s
=
aws_cloudwatch_event_rule
.
schedule
.
*.
arn
cloudwatch_rule_name
=
aws_cloudwatch_event_rule
.
schedule
.
name
cloudwatch_rule_name
s
=
aws_cloudwatch_event_rule
.
schedule
.
*.
name
}
}
output
"cloudwatch_rule_arn"
{
output
"cloudwatch_rule_arn
s
"
{
description
=
"ARN of the CloudWatch schedule rule."
description
=
"
List of
ARN
s
of the CloudWatch schedule rule
s
."
value
=
local
.
cloudwatch_rule_arn
value
=
local
.
cloudwatch_rule_arn
s
}
}
output
"cloudwatch_rule_name"
{
output
"cloudwatch_rule_name
s
"
{
description
=
"
N
ame of the CloudWatch schedule rule."
description
=
"
List of n
ame
s
of the CloudWatch schedule rule
s
."
value
=
local
.
cloudwatch_rule_name
value
=
local
.
cloudwatch_rule_name
s
}
}
resource
"aws_cloudwatch_event_target"
"schedule"
{
resource
"aws_cloudwatch_event_target"
"schedule"
{
count
=
length
(
local
.
function_alias_arns
)
count
=
length
(
local
.
function_alias_arns
)
arn
=
local
.
function_alias_arns
[
count
.
index
]
arn
=
local
.
function_alias_arns
[
count
.
index
]
rule
=
local
.
cloudwatch_rule_name
rule
=
local
.
cloudwatch_rule_name
s
[
count
.
index
]
depends_on
=
[
depends_on
=
[
aws_lambda_permission
.
cloudwatch
,
aws_lambda_permission
.
cloudwatch
,
]
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment