Examples#
Index > CloudFormation > Examples
Auto-generated documentation for CloudFormation type annotations stubs module types-boto3-cloudformation.
Client#
Implicit type annotations#
Can be used with types-boto3[cloudformation]
package installed.
Write your CloudFormation
code as usual,
type checking and code completion should work out of the box.
# CloudFormationClient usage example
from boto3.session import Session
session = Session()
client = session.client("cloudformation") # (1)
result = client.activate_type() # (2)
- client: CloudFormationClient
- result: ActivateTypeOutputTypeDef
# DescribeAccountLimitsPaginator usage example
from boto3.session import Session
session = Session()
client = session.client("cloudformation") # (1)
paginator = client.get_paginator("describe_account_limits") # (2)
for item in paginator.paginate(...):
print(item) # (3)
- client: CloudFormationClient
- paginator: DescribeAccountLimitsPaginator
- item: DescribeAccountLimitsOutputTypeDef
# ChangeSetCreateCompleteWaiter usage example
from boto3.session import Session
session = Session()
client = session.client("cloudformation") # (1)
waiter = client.get_waiter("change_set_create_complete") # (2)
waiter.wait()
- client: CloudFormationClient
- waiter: ChangeSetCreateCompleteWaiter
Explicit type annotations#
With types-boto3-lite[cloudformation]
or a standalone types_boto3_cloudformation
package, you have to explicitly specify client: CloudFormationClient
type annotation.
All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.
# CloudFormationClient usage example with type annotations
from boto3.session import Session
from types_boto3_cloudformation.client import CloudFormationClient
from types_boto3_cloudformation.type_defs import ActivateTypeOutputTypeDef
from types_boto3_cloudformation.type_defs import ActivateTypeInputRequestTypeDef
session = Session()
client: CloudFormationClient = session.client("cloudformation")
kwargs: ActivateTypeInputRequestTypeDef = {...}
result: ActivateTypeOutputTypeDef = client.activate_type(**kwargs)
# DescribeAccountLimitsPaginator usage example with type annotations
from boto3.session import Session
from types_boto3_cloudformation.client import CloudFormationClient
from types_boto3_cloudformation.paginator import DescribeAccountLimitsPaginator
from types_boto3_cloudformation.type_defs import DescribeAccountLimitsOutputTypeDef
session = Session()
client: CloudFormationClient = session.client("cloudformation")
paginator: DescribeAccountLimitsPaginator = client.get_paginator("describe_account_limits")
for item in paginator.paginate(...):
item: DescribeAccountLimitsOutputTypeDef
print(item)
# ChangeSetCreateCompleteWaiter usage example with type annotations
from boto3.session import Session
from types_boto3_cloudformation.client import CloudFormationClient
from types_boto3_cloudformation.waiter import ChangeSetCreateCompleteWaiter
session = Session()
client: CloudFormationClient = session.client("cloudformation")
waiter: ChangeSetCreateCompleteWaiter = client.get_waiter("change_set_create_complete")
waiter.wait()
Service Resource#
Implicit type annotations#
Can be used with types-boto3[cloudformation]
package installed.
# CloudFormationServiceResource usage example
from boto3.session import Session
session = Session()
resource = session.resource("cloudformation") # (1)
result = resource.get_available_subresources() # (2)
- resource: CloudFormationServiceResource
- result:
# ServiceResourceStacksCollection usage example
from boto3.session import Session
session = Session()
resource = session.resource("cloudformation") # (1)
collection = resource.stacks # (2)
for item in collection:
print(item) # (3)
- resource: CloudFormationServiceResource
- collection: CloudFormationServiceResource
- item: Stack
Explicit type annotations#
With types-boto3-lite[cloudformation]
or a standalone types_boto3_cloudformation
package, you have to explicitly specify
resource: CloudFormationServiceResource
type annotation.
All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.
# CloudFormationServiceResource usage example with type annotations
from boto3.session import Session
from types_boto3_cloudformation.service_resource import CloudFormationServiceResource
from types_boto3_cloudformation.service_resource import get_available_subresources
session = Session()
resource: CloudFormationServiceResource = session.resource("cloudformation")
result: get_available_subresources = resource.get_available_subresources()
# ServiceResourceStacksCollection usage example with type annotations
from boto3.session import Session
from types_boto3_cloudformation.service_resource import CloudFormationServiceResource
from types_boto3_cloudformation.service_resource import ServiceResourceStacksCollection
from types_boto3_cloudformation.service_resource import Stack
session = Session()
resource: CloudFormationServiceResource = session.resource("cloudformation")
collection: ServiceResourceStacksCollection = resource.stacks
for item in collection:
item: Stack
print(item)