Package: aws_terraform_registry
aws-terraform-registry-cliVersions followingSemantic VersioningOverviewThis project create a python client which work withAWS Terraform Private Registry.Features:Show client configuration (for debug purpose)Authentication:JWT Token generation.terraformrc generation to configure Devops workstationTerraform module publication from external storage (like a githb module release)Terraform module release (more detail on it below) to store every module inside default bucket of theAWS Terraform Private Registry..Seedocumentation.TheAWS Terraform Private Registryfollow this Architectural design:InstallationInstall this library directly into an activated virtual environment:$ python3 -m pip install aws_terraform_registryConfigurationWe have to provide few informations to this client :NameDescriptionsecret_key_nameAWS Secret manager name where JWT Secret is storedrepository_urlHTTPS endpoint of the registrydynamodb_table_nameAWS dynamodb table namebucket_namebucket namedefault_namespacedefault namespace to publish terraform module ("devops" per default)All this information can come from several way (choose the rigth for you):from a yaml configuration filefrom environment variableYaml configuration can be overriden with environment variable.YAML configurationThe default file name isterraform_registry.yaml, you can override this withTFR_CONFIG_FILEenvironmentt variable.To find thie configuratin file, directories will be lookup in this order:user home directorycommand line directory/etc/tfrEnvironment variableNameEnviromnent variable namesecret_key_nameTFR_SECRET_KEY_NAMErepository_urlTFR_REPOSITORY_URLdynamodb_table_nameTFR_DYNAMODB_TABLE_NAMEbucket_nameTFR_BUCKET_NAMEdefault_namespaceTFR_DEFAULT_NAMESPACEAll environment variable can be set with.envfile inside your command line directory.Usage>tfr
usage:tfr[-h]{config,generate-token,generate-terraformrc,publish,release}...

Manageterraformregistry

positionalarguments:{config,generate-token,generate-terraformrc,release,unpublish,publish}commandsconfigShowconfigurationparametersgenerate-tokenGenerateanaccesstokengenerate-terraformrcGenerateterraformrcconfigurationfilereleaseReleaseaterraformmodulefromcustomsource.publishPublishaterraformmodulefromcustomsource.unpublishUnpublishaterraformmodule(Keeparchiveons3).

optionalarguments:-h,--helpshowthishelpmessageandexitConfigurationYou can print what the python client use as configuration with the command :tfr configExample with an empty configuration:bucket_name:null
default_namespace:devops
dynamodb_table_name:null
repository_url:null
secret_key_name:nullAuthenticationObtain a JWT tokenCommand :usage:tfrgenerate-token[-h][-weeksWEEKS]optionalarguments:-h,--helpshowthishelpmessageandexit-weeksWEEKS,--weeksWEEKS#weeks of validity (52 per default)Configure terraform with your private registryUsers must create.terraformrcfile in their $HOME directory, with this content:credentials"registry.my-domain.com"{token="Mytoken"}Command :usage:tfrgenerate-terraformrc[-h]-output-directoryOUTPUT_DIRECTORY[-weeksWEEKS]optionalarguments:-h,--helpshowthishelpmessageandexit-output-directoryOUTPUT_DIRECTORY,--output-directoryOUTPUT_DIRECTORYoutputdirectory-weeksWEEKS,--weeksWEEKS#weeks of validity (52 per default)Terraform & PublicationYou have two way to publish a module, using:publishreleaseWhat's the difference ?publish: register the source module as is in the aws private terraform regstry. You could have access issue if this url is not public.release:store the source into the dedicated bucket of aws private terraform regstry. The access is managed within registry.archive (targ.gz) if the source is a folderdownload the source if it's an http urlAs your module will be stored within registry bucket, terraform client will use s3 signed urlWe usereleasefrom our ci/cd pipeline andpublishonly when we have to do something like 'quick and dirty' ... (It never happen, I swear !)Release commandusage:tfrrelease[-h][-namespaceNAMESPACE]-nameNAME-systemSYSTEM-versionVERSION-sourceSOURCE

optionalarguments:-h,--helpshowthishelpmessageandexit-namespaceNAMESPACE,--namespaceNAMESPACEmodulenamespace-nameNAME,--nameNAMEmodulename-systemSYSTEM,--systemSYSTEMmodulesystem(aws,...)-versionVERSION,--versionVERSIONmoduleversion-sourceSOURCE,--sourceSOURCEmodulesourceUnpublish commandusage:tfrunpublish[-h][-namespaceNAMESPACE]-nameNAME-systemSYSTEM-versionVERSION-sourceSOURCE

optionalarguments:-h,--helpshowthishelpmessageandexit-namespaceNAMESPACE,--namespaceNAMESPACEmodulenamespace-nameNAME,--nameNAMEmodulename-systemSYSTEM,--systemSYSTEMmodulesystem(aws,...)-versionVERSION,--versionVERSIONmoduleversionPublish commandusage:tfrpublish[-h][-namespaceNAMESPACE]-nameNAME-systemSYSTEM-versionVERSION-sourceSOURCE

optionalarguments:-h,--helpshowthishelpmessageandexit-namespaceNAMESPACE,--namespaceNAMESPACEmodulenamespace-nameNAME,--nameNAMEmodulename-systemSYSTEM,--systemSYSTEMmodulesystem(aws,...)-versionVERSION,--versionVERSIONmoduleversion-sourceSOURCE,--sourceSOURCEmodulesource