def _get_stack_from_s3_url(self, template_url): template_url_parts = urlparse(template_url) bucket_name = template_url_parts.netloc.split(".")[0] key_name = template_url_parts.path.lstrip("/") key = s3_backend.get_key(bucket_name, key_name) return key.value.decode("utf-8")
def transform_mapping(self): for k, v in self._template.get("Mappings", {}).items(): if "Fn::Transform" in v: name = v["Fn::Transform"]["Name"] params = v["Fn::Transform"]["Parameters"] if name == "AWS::Include": location = params["Location"] bucket_name, name = bucket_and_name_from_url(location) key = s3_backend.get_key(bucket_name, name) self._parsed_resources.update(json.loads(key.value))
def _get_stack_from_s3_url(self, template_url): template_url_parts = urlparse(template_url) if "localhost" in template_url: bucket_name, key_name = template_url_parts.path.lstrip("/").split( "/", 1) else: if template_url_parts.netloc.endswith('amazonaws.com') \ and template_url_parts.netloc.startswith('s3'): # Handle when S3 url uses amazon url with bucket in path # Also handles getting region as technically s3 is region'd # region = template_url.netloc.split('.')[1] bucket_name, key_name = template_url_parts.path.lstrip( "/").split("/", 1) else: bucket_name = template_url_parts.netloc.split(".")[0] key_name = template_url_parts.path.lstrip("/") key = s3_backend.get_key(bucket_name, key_name) return key.value.decode("utf-8")
def _get_stack_from_s3_url(self, template_url): template_url_parts = urlparse(template_url) if "localhost" in template_url: bucket_name, key_name = template_url_parts.path.lstrip( "/").split("/", 1) else: if template_url_parts.netloc.endswith('amazonaws.com') \ and template_url_parts.netloc.startswith('s3'): # Handle when S3 url uses amazon url with bucket in path # Also handles getting region as technically s3 is region'd # region = template_url.netloc.split('.')[1] bucket_name, key_name = template_url_parts.path.lstrip( "/").split("/", 1) else: bucket_name = template_url_parts.netloc.split(".")[0] key_name = template_url_parts.path.lstrip("/") key = s3_backend.get_key(bucket_name, key_name) return key.value.decode("utf-8")