dda-devops-build/doc/example/20_terrform_1_0/build.py

55 lines
1.4 KiB
Python
Raw Normal View History

2021-10-15 12:08:12 +00:00
from os import environ
from pybuilder.core import task, init
from ddadevops import *
name = 'my-project'
MODULE = 'my-module'
PROJECT_ROOT_PATH = '../../..'
class MyBuild(AwsBackendPropertiesMixin, DevopsTerraformBuild):
pass
@init
def initialize(project):
2022-08-19 12:37:37 +00:00
project.build_depends_on('ddadevops>=1.0')
2021-10-15 12:08:12 +00:00
stage = environ['STAGE']
print('Doing stage: ', stage)
config = create_devops_terraform_build_config(stage,
PROJECT_ROOT_PATH,
MODULE,
{},
use_workspace=False,
2022-08-19 12:37:37 +00:00
terraform_semantic_version="1.0.8")
2021-10-15 12:08:12 +00:00
config = add_aws_backend_properties_mixin_config(config, 'prod')
build = MyBuild(project, config)
build.initialize_build_dir()
@task
def plan(project):
build = get_devops_build(project)
build.plan()
@task
def tf_apply(project):
build = get_devops_build(project)
build.apply(True)
@task
def apply(project):
build = get_devops_build(project)
build.apply(True)
@task
def destroy(project):
build = get_devops_build(project)
build.destroy(True)
@task
def tf_import(project):
build = get_devops_build(project)
build.tf_import('aws_route53_record.v4', 'my-resource-id')