tb_pulumi¶
Standardization library for the usage of Pulumi in Python at Thunderbird. For an overview of how to use this library, read the Getting Started page.
- class tb_pulumi.ThunderbirdComponentResource(pulumi_type: str, name: str, project: ThunderbirdPulumiProject, opts: ResourceOptions = None, tags: dict = {})¶
Bases:
ComponentResource
A special kind of pulumi.ComponentResource which handles common elements of resources such as naming and tagging. All such resources must belong to a
tb_pulumi.ThunderbirdPulumiProject
.- Parameters:
pulumi_type (str) – The “type” string (commonly referred to in docs as just
t
) of the component as described by Pulumi’s docs.name (str) – An identifier for this set of resources. Generally, this gets used as part of all resources defined by the ComponentResource.
project (
tb_pulumi.ThunderbirdPulumiProject
) – The project this resource belongs to.opts (pulumi.ResourceOptions, optional) – Additional
pulumi.ResourceOptions
to apply to this resource. Defaults to None.tags (dict, optional) – Key/value pairs to merge with the default tags which get applied to all resources in this group. Defaults to {}.
- finish(outputs: dict[str, Any], resources: dict[str, Resource | list[Resource]])¶
Registers the provided
outputs
as Pulumi outputs for the module. Also stores the mapping ofresources
internally as theresources
member where they it be acted on collectively by aThunderbirdPulumiProject
. Any implementation of this class should call this function at the end of its__init__
function to ensure its state is properly represented.Values in
resources
should be either a Resource or derivative (such as a ThunderbirdComponentResource) or a list of such.
- name: str¶
Identifier for this set of resources.
- project: ThunderbirdPulumiProject¶
Project this resource is a member of.
- property protect_resources: bool¶
Determines whether resources should have protection against changes enabled based on the project’s configuration. Unprotected resources are not part of a protected stack, or you have run Pulumi with
TBPULUMI_DISABLE_PROTECTION=True
set in your environment.
- resources: dict¶
Resources which are members of this ComponentResource.
- tags: dict¶
Tags to apply to all taggable resources
- class tb_pulumi.ThunderbirdPulumiProject(protected_stacks: list[str] = ['prod'])¶
Bases:
object
A collection of related Pulumi resources upon which we can take bulk/collective actions. This class enforces some usage conventions that help keep us organized and consistent.
- Parameters:
protected_stacks (list[str], optional) – List of stack names which should require explicit instruction to modify. Defaults to
tb_pulumi.constants.DEFAULT_PROTECTED_STACKS
.
- aws_account_id: str¶
Account number that the currently configured AWS user/role is a member of, in which Pulumi will act.
- aws_region: str¶
Currently configured AWS region
- property config: dict¶
Provides read-only access to the project configuration, which is expected to be in the root of your Pulumi project directory, and should match the current stack. For example,
config.preprod.yaml
would be a configuration for an environment called “preprod”.
- flatten() set[Resource] ¶
Returns a flat set of all resources existing within this project.
- get_aws_client(service: str)¶
Retrieves an AWS client for the requested service, preferably from a cache. Caches any clients it creates.
- Parameters:
service (str) – Name of the service as described in boto3 docs
- project: str¶
Name of the Pulumi project
- pulumi_config: Config¶
Pulumi configuration data referencing Pulumi.stack.yaml
- resources: dict¶
Pulumi Resource objects managed by this project
- stack: str¶
Name of the Pulumi stack
- tb_pulumi.env_var_is_true(name: str) bool ¶
Determines if the value of the given environment variable represents “True” in some way.
- Parameters:
name (str) – The environment variable to check
- Returns:
True if the value of the environment variable looks like it is set to an affirmative value, otherwise False.
- Return type:
bool
- tb_pulumi.env_var_matches(name: str, matches: list[str], default: bool = False) bool ¶
Determines if the value of the given environment variable is in the given list. This is a case-insensitive check.
- Parameters:
name (str) – The environment variable to check
matches (list[str]) – A list of strings to match against
default (bool, optional) – Default value if the variable doesn’t match. Defaults to False.
- Returns:
True if the value of the given environment variable is in the given list, the provided default value if it is not, or None if the variable is unset.
- Return type:
bool
name:
matches:
default:
- tb_pulumi.flatten(item: dict | list | ThunderbirdComponentResource | Resource) set[Resource] ¶
Recursively traverses a nested collection of Pulumi
Resource
s, converting them into a flat set which can be more easily iterated over.- Parameters:
item (dict | list | ThunderbirdComponentResource) – Either a Pulumi
Resource
object, or some collection thereof. The following types of collections are supported:dict
,list
,ThunderbirdComponentResource
.- Returns:
A
set
of PulumiResource
s contained within the collection.- Return type:
set(pulumi.Resource)