https://pulumi.com logo
#aws
Title
# aws
b

billions-forest-38488

02/11/2020, 4:43 PM
Hi, would someone mind pointing me in the right direction: Using Python pulumi_aws, going really well, but I'm stuck on something: I'm trying to kick off a Cloudformation stack that uses
Outputs
from another stack, for example, this CFN stack has some EC2's with SGs:
Copy code
VpcId:
        Fn::ImportValue: !Sub '${Env}-vpc'
However, I'm unsure how to inject these into
cloudformation.Stack()
as it no longer nested
m

many-garden-84306

02/11/2020, 4:51 PM
If you’re trying to replace what was once a cloudformation stack that set up the vpc and exported the vpc Id with a pulumi stack that sets up the vpc, then I think you have two choices: 1: change the dependent cloudformation stack to take the vpc as an input rather than importing it. 2. Replace the old vpc cloudformation stack with a new dummy cloudformation stack that takes the vpc is as input, then exports it so it can be imported by the other cloudformation stack.
b

billions-forest-38488

02/11/2020, 4:52 PM
^ thanks - I just started doing No.1 - didn't think about doing No.2! Thanks, going to look into No.2 right now.
m

many-garden-84306

02/11/2020, 5:04 PM
If you do #2 you may need to make the dependent cloudformation stack explicitly dependent on the dummy cloudformation stack in pulumi, because the cf import is not derived from any pulumi output and hence pulumi won’t implicitly see the dependency
b

billions-forest-38488

02/11/2020, 5:18 PM
@many-garden-84306 doing the dummy stack works an absolute treat!!
Copy code
dummy_vpc = cloudformation.Stack(
    'DummyVpc',
    name=f'{Env}-vpc',
    parameters={
        'Env': Env,
        'VpcId': vpc.id,
        'VpcCidr': vpc.cidr_block,
        'SubnetPublic1': vpc_subnet_data['PublicSubnet1'],
        'SubnetPublic2': vpc_subnet_data['PublicSubnet2'],
        'SubnetPublic3': vpc_subnet_data['PublicSubnet3'],
        'SubnetPrivate1': vpc_subnet_data['PrivateSubnet1'],
        'SubnetPrivate2': vpc_subnet_data['PrivateSubnet2'],
        'SubnetPrivate3': vpc_subnet_data['PrivateSubnet3'],
        'SubnetPrivate1Cidr': vpc_subnet_data['SubnetPrivate1Cidr'],
        'SubnetPrivate2Cidr': vpc_subnet_data['SubnetPrivate2Cidr'],
        'SubnetPrivate3Cidr': vpc_subnet_data['SubnetPrivate3Cidr'],
        'VpcSecurityGroup': vpc.default_security_group_id
    },
    template_body=open('formations/vpc_dummy.yml').read(),
)
thank you! literally saved me hours banging my head against the table!
m

many-garden-84306

02/11/2020, 6:37 PM
You're welcome!