-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathmain.tf
78 lines (62 loc) · 2.68 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# RUN PEX BINARY AS DATA SOURCE AND PROVISIONER
# These templates show an example of how to run a pex binary as an external data source or local-exec provisioner in
# terraform in a portable manner that can work with multiple platforms and python versions.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
terraform {
required_version = ">= 1.0.0"
}
# Run the PEX binary as a local-exec provisioner on a null_resource.
module "pex_resource" {
# When using these modules in your own templates, you will need to use a Git URL with a ref attribute that pins you
# to a specific version of the modules, such as the following example:
# source = "git::git@github.com:gruntwork-io/terraform-aws-utilities.git//modules/run-pex-as-resource?ref=v1.0.8"
source = "../../modules/run-pex-as-resource"
triggers = var.triggers
# Path components to each of the PEX binary
python_pex_path_parts = [
path.module,
"pex-env",
"bin",
"sample_python_script_py3_env.pex",
]
# Path components to the folder that holds the python modules for sample_python_script
pex_module_path_parts = [
path.module,
]
# The entrypoint of the sample_python_script, encoded as MODULE:FUNCTION
script_main_function = "sample_python_script.main:main"
env = {
RUN_PEX_TEST_ENV = var.echo_string
}
pass_in_previous_triggers = true
previous_trigger_option = "--triggers-json"
enabled = var.enabled
}
# Run the PEX binary as a data source.
module "pex_data" {
# When using these modules in your own templates, you will need to use a Git URL with a ref attribute that pins you
# to a specific version of the modules, such as the following example:
# source = "git::git@github.com:gruntwork-io/terraform-aws-utilities.git//modules/run-pex-as-data-source?ref=v1.0.8"
source = "../../modules/run-pex-as-data-source"
# Path components to each of the PEX binary
python_pex_path_parts = [
path.module,
"pex-env",
"bin",
"sample_python_script_py3_env.pex",
]
# Path components to the folder that holds the python modules for sample_python_script
pex_module_path_parts = [
path.module,
]
# The entrypoint of the sample_python_script, encoded as MODULE:FUNCTION
script_main_function = "sample_python_script.main:main"
# Argument to be passed to the entrypoint of sample_python_script
command_args = "--is-data"
# Query parameter for the data source, that will be passed into the script in json format
command_query = {
"echo" = var.echo_string
}
enabled = var.enabled
}