本文整理汇总了Python中troposphere.Template.AWSTemplateFormatVersion方法的典型用法代码示例。如果您正苦于以下问题:Python Template.AWSTemplateFormatVersion方法的具体用法?Python Template.AWSTemplateFormatVersion怎么用?Python Template.AWSTemplateFormatVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类troposphere.Template
的用法示例。
在下文中一共展示了Template.AWSTemplateFormatVersion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Template
# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import AWSTemplateFormatVersion [as 别名]
#
# Run: python SonarQube.py
# Debug: python -m pdb SonarQube.py
#
from troposphere import Parameter, Template, Ref, Tags, Select, GetAZs, Join, Output, GetAtt, Base64
from troposphere.iam import InstanceProfile, Role
from troposphere import cloudformation
from troposphere.rds import DBInstance, DBParameterGroup
import troposphere.ec2 as ec2
SONARQUBE_PATH = '/opt/sonarqube/sonarqube.zip'
t = Template(Description='SonarQube instance')
t.AWSTemplateFormatVersion = '2010-09-09'
keyname = t.add_parameter(
Parameter(
'KeyName',
Type='AWS::EC2::KeyPair::KeyName',
ConstraintDescription=('must be the name of an existing EC2 '
'KeyPair.'),
Description=('Name of an existing EC2 KeyPair to enable SSH '
'access to the instance')
)
)
your_ip_address = t.add_parameter(
Parameter(
'YourIpAddress',
示例2: do_template
# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import AWSTemplateFormatVersion [as 别名]
def do_template(self):
t = Template(Description=self.description)
t.AWSTemplateFormatVersion = '2010-09-09'
t.add_parameter(
Parameter(
'KeyName',
Type='AWS::EC2::KeyPair::KeyName',
ConstraintDescription=('must be the name of an existing EC2 '
'KeyPair.'),
Description=('Name of an existing EC2 KeyPair to enable SSH '
'access to the instance')
)
)
queue = t.add_resource(
sqs.Queue(
'DLQLambdaQueue',
QueueName='DLQLambdaQueue',
DelaySeconds=0,
# Long polling. See: http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-long-polling.html#sqs-long-polling-console
# 20 seconds
ReceiveMessageWaitTimeSeconds=20,
# 256KiB (bytes)
MaximumMessageSize=262144,
# 30 seconds
VisibilityTimeout=30,
# 14 days (seconds)
MessageRetentionPeriod=1209600
)
)
role = t.add_resource(
iam.Role(
'GusLambdaRole',
RoleName='GusLambdaRole',
# Trust relationships
AssumeRolePolicyDocument={
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
},
Path='/gus-lambda/',
# Permissions
# Managed Policies
ManagedPolicyArns=[
'arn:aws:iam::aws:policy/AmazonSQSFullAccess',
'arn:aws:iam::aws:policy/AWSLambdaFullAccess',
'arn:aws:iam::aws:policy/AWSLambdaExecute',
'arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess',
('arn:aws:iam::aws:policy/service-role/'
'AWSLambdaVPCAccessExecutionRole'),
],
# Inline Policies
Policies=[
iam.Policy(
PolicyName='gus-inline-policy',
PolicyDocument={
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:CreateNetworkInterface",
"ec2:DeleteNetworkInterface",
"ec2:DescribeNetworkInterfaces"
],
"Resource": "*"
}
]
}
)
]
)
)
lambda_function = t.add_resource(
Function(
"GusLambdaFunction",
Description='aws-lambda-gus-example',
FunctionName='aws-lambda-gus-example',
# size 320MB
MemorySize='320',
Environment=Environment(
Variables={'ENVIRONMENT_GUS': 'GUSTAVO'}
),
Code=Code(
S3Bucket='guslambda',
S3Key='aws-example-lambda-1.0-SNAPSHOT-jar-with-dependencies.jar'
),
# time out 15 seconds
Timeout=15,
#.........这里部分代码省略.........