def test_attr_map_access(): secrets = Data("aws_kms_secrets", "test", secret=[ { "name": "foo", "payload": "bar", }, ]) assert secrets.plaintext[ "foo"] == '${data.aws_kms_secrets.test.plaintext.foo}'
def test_equality(): # NamedObject p1 = Provider("mysql", host="db") p2 = Provider("mysql", host="db") v1 = Variable("mysql", host="db") assert p1 == p2 assert p1 != v1 # TypedObject r1 = Resource("aws_security_group", "sg", name="sg") r2 = Resource("aws_security_group", "sg", name="sg") d1 = Data("aws_security_group", "sg", name="sg") assert r1 == r2 assert r1 != d1 # Invalid comparisons assert r1 != "string" assert r1 != 0
def test_typed_object(): ami = Data("aws_ami", "ecs_ami", most_recent=True, filter=[ dict(name="name", values=["*amazon-ecs-optimized"]), dict(name="owner-alias", values=["amazon"]), ]) assert ami._type == 'aws_ami' assert ami._name == 'ecs_ami' assert ami._values == { 'most_recent': True, 'filter': [ dict(name="name", values=["*amazon-ecs-optimized"]), dict(name="owner-alias", values=["amazon"]), ] }
def test_typed_object(): ami = Data( "aws_ami", "ecs_ami", most_recent=True, filter=[ dict(name="name", values=["*amazon-ecs-optimized"]), dict(name="owner-alias", values=["amazon"]), ], ) assert ami._type == "aws_ami" assert ami._name == "ecs_ami" assert ami._values == { "most_recent": True, "filter": [ dict(name="name", values=["*amazon-ecs-optimized"]), dict(name="owner-alias", values=["amazon"]), ], }
from terraformpy import Data, Provider, Resource # we build our launch configs based on the following data # each key should be an instance type and the value should be a tuple: (price, vCPUs) spot_config = { 'c4.large': (0.105, 2), 'c4.xlarge': (0.209, 4), 'c4.2xlarge': (0.419, 8), } Provider('aws', region='us-west-2', profile='nwdev') vpc = Data('terraform_remote_state', 'vpc', backend='s3', config=dict(bucket='nw-terraform', key='devops/vpc.tfstate', region='us-east-1', profile='nwprod')) ami = Data('aws_ami', 'ecs_ami', most_recent=True, filter=[ dict(name='name', values=['*amazon-ecs-optimized']), dict(name='owner-alias', values=['amazon']) ]) spot_fleet_role = Resource('aws_iam_role', 'spot_fleet', name='spot_fleet',
Terraform(backend=dict(s3=dict( region="us-east-1", bucket="terraform-tfstate-bucket", key="terraform.tfstate", workspace_key_prefix="my_prefix", dynamodb_table="terraform_locks", ))) Provider("aws", region="us-west-2", profile="nwdev") vpc = Data( "terraform_remote_state", "vpc", backend="s3", config=dict( bucket="nw-terraform", key="devops/vpc.tfstate", region="us-east-1", profile="nwprod", ), ) ami = Data( "aws_ami", "ecs_ami", most_recent=True, filter=[ dict(name="name", values=["*amazon-ecs-optimized"]), dict(name="owner-alias", values=["amazon"]), ], )