Reference
This part of the project documentation focuses on an information-oriented approach. Use it as a reference for the technical implementation of the aws_terraform_registry
project code.
ApplicationConfig
dataclass
Define aws terraform private registry parameters.
Attributes:
secret_key_name (str): AWS Secret manager name where JWT Secret is stored
repository_url (str): HTTPS endpoint of the registry
dynamodb_table_name (str): dynamodb table name
bucket_name (str): bucket name
default_namespace: default namespace to publish terrafor module ("devops" per default)
Source code in aws_terraform_registry/config.py
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 79 80 81 82 83 |
|
__post_init__()
Finalize configuration.
Feed attributs from TFR_xxxx env variable if exists.
Source code in aws_terraform_registry/config.py
39 40 41 42 43 44 45 46 47 48 49 |
|
load_from(filename)
classmethod
Load ApplicationConfig from a yaml file.
Source code in aws_terraform_registry/config.py
79 80 81 82 83 |
|
validate()
Validate each attributs.
Raise
(RuntimeError): if an attribut is empty
Source code in aws_terraform_registry/config.py
51 52 53 54 55 56 57 58 59 60 61 |
|
TerraformModuleIdentifier
dataclass
Define a Terraform Module Identifier.
Attributes:
namespace (str): is the name of a namespace, unique on a particular hostname,
that can contain one or more modules that are somehow related.
name (str): the module name
system (str): the name of a remote system that the module is primarily written to target,
like aws or azurerm
Source code in aws_terraform_registry/common/model.py
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 |
|
get_blob_url(repository_url, version)
Return registry url with blob api.
Source code in aws_terraform_registry/common/model.py
45 46 47 |
|
get_bucket_key(version)
Return bucket key.
Source code in aws_terraform_registry/common/model.py
32 33 34 |
|
get_publish_url(bucket_name, version)
Return s3 url.
Source code in aws_terraform_registry/common/model.py
36 37 38 39 40 41 42 43 |
|
build_parser(config)
Build arguments parser.
Source code in aws_terraform_registry/cli.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
generate_terraformrc(config, output_directory, weeks=52)
Generate terraform_rc file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
ApplicationConfig
|
application configuration. |
required |
output_directory |
str
|
directory where to wrote the .terraform_rc. |
required |
weeks |
int
|
weeks of validity (52 per default). |
52
|
Source code in aws_terraform_registry/common/token.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
generate_token(config, weeks=1)
Generate a JWT tokecm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
ApplicationConfig
|
application configuration. |
required |
weeks |
int
|
weeks of validity (1 per default). |
1
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
encoded jwt token |
Source code in aws_terraform_registry/common/token.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
publish_module(config, terraform_module, version, source)
Publish terraform module.
Args:
config (ApplicationConfig): application configuration
terraform_module (TerraformModuleIdentifier): module identifier
version (str): version to publish
source (str): module source
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
source |
Raises:
Type | Description |
---|---|
RuntimeError
|
if specified version and module is ever published. |
Source code in aws_terraform_registry/common/publish.py
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 |
|
release_module(config, terraform_module, version, source)
Release a terraform module.
Source could be:
- a local folder (In this case local folder will be targzified).
- an url which point to a targzified archive (like a git release)
This source will be send to the default bucket and publish onto the registry.
Args:
config (ApplicationConfig): application configuration
terraform_module (TerraformModuleIdentifier): module identifier
version (str): version to publish
source (str): module source
Raise
(RuntimeError): if source did not exists or if specified version and module is ever published.
Source code in aws_terraform_registry/common/release.py
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 |
|
unpublish_module(config, terraform_module, version)
UnPublish terraform module.
Args:
config (ApplicationConfig): application configuration
terraform_module (TerraformModuleIdentifier): module identifier
version (str): version to publish
Raises:
Type | Description |
---|---|
RuntimeError
|
if specified version and module did not exists. |
Source code in aws_terraform_registry/common/publish.py
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 79 |
|