Merge pull request #680 from SplunkStorm/setup_s3_cfn_parsing
Setup s3 cfn parsing
This commit is contained in:
commit
e92a8b7492
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,3 +11,4 @@ build/
|
|||||||
.idea/
|
.idea/
|
||||||
*.swp
|
*.swp
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
python_env
|
@ -14,6 +14,7 @@ from moto.kms import models as kms_models
|
|||||||
from moto.rds import models as rds_models
|
from moto.rds import models as rds_models
|
||||||
from moto.redshift import models as redshift_models
|
from moto.redshift import models as redshift_models
|
||||||
from moto.route53 import models as route53_models
|
from moto.route53 import models as route53_models
|
||||||
|
from moto.s3 import models as s3_models
|
||||||
from moto.sns import models as sns_models
|
from moto.sns import models as sns_models
|
||||||
from moto.sqs import models as sqs_models
|
from moto.sqs import models as sqs_models
|
||||||
from .utils import random_suffix
|
from .utils import random_suffix
|
||||||
@ -57,6 +58,7 @@ MODEL_MAP = {
|
|||||||
"AWS::Route53::RecordSet": route53_models.RecordSet,
|
"AWS::Route53::RecordSet": route53_models.RecordSet,
|
||||||
"AWS::Route53::RecordSetGroup": route53_models.RecordSetGroup,
|
"AWS::Route53::RecordSetGroup": route53_models.RecordSetGroup,
|
||||||
"AWS::SNS::Topic": sns_models.Topic,
|
"AWS::SNS::Topic": sns_models.Topic,
|
||||||
|
"AWS::S3::Bucket": s3_models.FakeBucket,
|
||||||
"AWS::SQS::Queue": sqs_models.Queue,
|
"AWS::SQS::Queue": sqs_models.Queue,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,6 +288,16 @@ class FakeBucket(object):
|
|||||||
def set_acl(self, acl):
|
def set_acl(self, acl):
|
||||||
self.acl = acl
|
self.acl = acl
|
||||||
|
|
||||||
|
@property
|
||||||
|
def physical_resource_id(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def create_from_cloudformation_json(
|
||||||
|
cls, resource_name, cloudformation_json, region_name):
|
||||||
|
bucket = s3_backend.create_bucket(resource_name, region_name)
|
||||||
|
return bucket
|
||||||
|
|
||||||
|
|
||||||
class S3Backend(BaseBackend):
|
class S3Backend(BaseBackend):
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import sure # noqa
|
|||||||
from moto.cloudformation.models import FakeStack
|
from moto.cloudformation.models import FakeStack
|
||||||
from moto.cloudformation.parsing import resource_class_from_type, parse_condition
|
from moto.cloudformation.parsing import resource_class_from_type, parse_condition
|
||||||
from moto.sqs.models import Queue
|
from moto.sqs.models import Queue
|
||||||
|
from moto.s3.models import FakeBucket
|
||||||
from boto.cloudformation.stack import Output
|
from boto.cloudformation.stack import Output
|
||||||
from boto.exception import BotoServerError
|
from boto.exception import BotoServerError
|
||||||
|
|
||||||
@ -23,6 +24,10 @@ dummy_template = {
|
|||||||
"VisibilityTimeout": 60,
|
"VisibilityTimeout": 60,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"S3Bucket": {
|
||||||
|
"Type": "AWS::S3::Bucket",
|
||||||
|
"DeletionPolicy": "Retain"
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,12 +90,16 @@ def test_parse_stack_resources():
|
|||||||
parameters={},
|
parameters={},
|
||||||
region_name='us-west-1')
|
region_name='us-west-1')
|
||||||
|
|
||||||
stack.resource_map.should.have.length_of(1)
|
stack.resource_map.should.have.length_of(2)
|
||||||
list(stack.resource_map.keys())[0].should.equal('Queue')
|
|
||||||
queue = list(stack.resource_map.values())[0]
|
queue = stack.resource_map['Queue']
|
||||||
queue.should.be.a(Queue)
|
queue.should.be.a(Queue)
|
||||||
queue.name.should.equal("my-queue")
|
queue.name.should.equal("my-queue")
|
||||||
|
|
||||||
|
bucket = stack.resource_map['S3Bucket']
|
||||||
|
bucket.should.be.a(FakeBucket)
|
||||||
|
bucket.physical_resource_id.should.equal(bucket.name)
|
||||||
|
|
||||||
|
|
||||||
@patch("moto.cloudformation.parsing.logger")
|
@patch("moto.cloudformation.parsing.logger")
|
||||||
def test_missing_resource_logs(logger):
|
def test_missing_resource_logs(logger):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user