You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/terraform/v1.14.x (beta)/docs/language/block/action.mdx
+38-24Lines changed: 38 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -193,28 +193,36 @@ The following examples show how to write configuration for common use cases.
193
193
194
194
### Define an action
195
195
196
-
The following example adds an `aws_lambda_invoke` action. You can invoke an action using the CLI or configure Terraform to invoke the action during a resource lifecycle state.
196
+
The following example adds an `aws_lambda_invoke` action. You can invoke an action using the CLI or configure Terraform to invoke the action during a resource lifecycle state.
197
197
198
198
```hcl
199
199
action "aws_lambda_invoke" "example" {
200
200
config {
201
-
values = var.values
202
-
timeout = 3000
201
+
function_name = "my_function"
202
+
payload = jsonencode({
203
+
key1 = "value1"
204
+
key2 = "value2"
205
+
})
203
206
}
204
207
}
205
208
```
206
209
210
+
The value of the `function_name` argument must be defined elsewhere in the configuration. The argument is available in the AWS `lambda_function` resource. Refer to the [AWS provider documentation](https://registry.terraform.io/providers/hashicorp/aws/6.14.0/docs/resources/lambda_function#basic-function-with-nodejs) for information about provisioning an AWS Lambda function.
211
+
207
212
### Select an alternate provider configuration
208
213
209
214
The following example configures Terraform to apply the `aws.alias` provider configuration when invoking the action:
210
215
211
216
```hcl
212
-
action "aws_lambda_invocation" "example" {
213
-
provider = aws.alias
214
-
config {
215
-
input = count.index
216
-
timeout = 3000
217
-
}
217
+
action "aws_lambda_invoke" "example" {
218
+
provider = aws.alias
219
+
config {
220
+
function_name = "my_function"
221
+
payload = jsonencode({
222
+
key1 = "value1"
223
+
key2 = "value2"
224
+
})
225
+
}
218
226
}
219
227
```
220
228
@@ -229,12 +237,15 @@ You can add a `count` or `for_each` meta-argument to invoke an action multiple t
0 commit comments