Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prototype new auto-generation via the AWS resource specification file #1300

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ spec:
unzip -d spec CloudFormationResourceSpecification.zip
rm CloudFormationResourceSpecification.zip

spec2:
curl -O https://d1uauaxba7bl26.cloudfront.net/latest/CloudFormationResourceSpecification.json

2to3:
2to3 -n -w examples > 2to3-examples.patch
2to3 -n -w troposphere > 2to3-troposphere.patch
Expand Down
42 changes: 42 additions & 0 deletions batch_validator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from .validators import exactly_one


class LaunchTemplateSpecificationMixin(object):
def validate(self):
template_ids = [
'LaunchTemplateId',
'LaunchTemplateName'
]
exactly_one(self.__class__.__name__, self.properties, template_ids)


def validate_environment_state(environment_state):
""" Validate response type
:param environment_state: State of the environment
:return: The provided value if valid
"""
valid_states = [
"ENABLED",
"DISABLED"
]
if environment_state not in valid_states:
raise ValueError(
"{} is not a valid environment state".format(environment_state)
)
return environment_state


def validate_queue_state(queue_state):
""" Validate response type
:param queue_state: State of the queue
:return: The provided value if valid
"""
valid_states = [
"ENABLED",
"DISABLED"
]
if queue_state not in valid_states:
raise ValueError(
"{} is not a valid queue state".format(queue_state)
)
return queue_state
8 changes: 4 additions & 4 deletions examples/S3_Bucket_With_Versioning_And_Lifecycle_Rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from troposphere import Output, Ref, Template
from troposphere.s3 import Bucket, PublicRead, VersioningConfiguration, \
LifecycleConfiguration, LifecycleRule, NoncurrentVersionTransition, \
LifecycleRuleTransition
LifecycleConfiguration, Rule, NoncurrentVersionTransition, \
Transition

t = Template()

Expand All @@ -30,15 +30,15 @@

LifecycleConfiguration=LifecycleConfiguration(Rules=[
# Add a rule to
LifecycleRule(
Rule(
# Rule attributes
Id="S3BucketRule001",
Prefix="/only-this-sub-dir",
Status="Enabled",
# Applies to current objects
ExpirationInDays=3650,
Transitions=[
LifecycleRuleTransition(
Transition(
StorageClass="STANDARD_IA",
TransitionInDays=60,
),
Expand Down
Loading