Created
July 6, 2023 17:57
-
-
Save jaxxstorm/0800bf6f500ce143a4e41cabcc065f9c to your computer and use it in GitHub Desktop.
Stack Reference Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import infrastructure_lib.stackinfo as stackinfo | |
STACK = pulumi.get_stack() | |
vpc = stackinfo.VpcStackInfo(STACK) | |
# you can pass these values to another resource | |
vpc.vpc_id | |
vpc.private_subnets | |
vpc.public_subnets | |
db = database.PrivateDatabase( | |
"secret-db", | |
args=database.PrivateDatabaseArgs( | |
vpc_id=vpc.vpc_id, | |
subnet_ids=vpc.private_subnet_ids, | |
db_name="secret", | |
username="secret", | |
) | |
) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Any | |
import pulumi | |
class VpcStackInfo(pulumi.StackReference): | |
vpc_id = pulumi.Output[Any] | |
private_subnet_ids = pulumi.Output[Any] | |
public_subnet_ids = pulumi.Output[Any] | |
cidr_block = pulumi.Output[Any] | |
def __init__(self, stack_name: str): | |
super().__init__(f"my_org/vpc/{stack_name}") | |
self.vpc_id = self.require_output("vpc_id") # type: ignore | |
self.private_subnet_ids = self.require_output("private_subnet_ids") # type: ignore | |
self.public_subnet_ids = self.require_output("public_subnet_ids") # type: ignore | |
self.cidr_block = self.require_output("cidr_block") # type: ignore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment