def add_s3(self): self.s3 = self.template.add_resource(Bucket( "S3Bucket", BucketName=self.sceptre_user_data["bucket_name"], AccessControl=PublicRead, WebsiteConfiguration=WebsiteConfiguration( IndexDocument="index.html", ErrorDocument="error.html" ) ))
def build(prefix, template, suffix=None): """ Adds S3 and CloudFront elements to CF template. """ s3bucket = template.add_resource( Bucket("%sS3Bucket" % prefix, AccessControl=PublicRead, WebsiteConfiguration=WebsiteConfiguration( IndexDocument="index.html"), BucketName=resource_title.bucket_name(prefix, suffix))) template.add_output([ Output("WebsiteURL", Value=GetAtt(s3bucket, "WebsiteURL"), Description="URL for website hosted on S3") ])
def create_s3_bucket(self): t = self.template self.s3Bucket = t.add_resource( Bucket("testS3Bucket", AccessControl=PublicRead, WebsiteConfiguration=WebsiteConfiguration( IndexDocument="index.html", ErrorDocument="error.html"))) t.add_output([ Output("WebsiteURL", Value=GetAtt(self.s3Bucket, "WebsiteURL"), Description="URL for website hosted on S3"), Output("S3BucketSecureURL", Value=Join("", ["http://", GetAtt(self.s3Bucket, "DomainName")]), Description="Name of S3 bucket to hold website content"), ])
def add_bucket(template: Template) -> Bucket: bucket = template.add_resource( Bucket("recordsui", AccessControl=PublicRead, WebsiteConfiguration=WebsiteConfiguration( IndexDocument="index.html", ErrorDocument="error.html"))) template.add_output([ Output("WebsiteURL", Value=GetAtt(bucket, "WebsiteURL"), Description="URL for website hosted on S3"), Output("S3BucketSecureURL", Value=Join("", ["http://", GetAtt(bucket, "DomainName")]), Description="Name of S3 bucket to hold website content"), ]) return bucket
"hostedzoneID": "Z2FDTNDATAQYW2" } }) HostedZoneName = t.add_parameter( Parameter( "HostedZoneName", Description="The DNS name of an existing Amazon Route 53 hosted zone", Type="String")) # prepare different configuration for www to root and vice versa if www_to_root: print("Redirecting www to root domain.") aliases = [Ref(HostedZoneName)] bucket_website_conf = WebsiteConfiguration( IndexDocument=config["index_document"], ErrorDocument=config["error_document"]) www_bucket_website_conf = WebsiteConfiguration( RedirectAllRequestsTo=RedirectAllRequestsTo( Protocol='http', HostName=Ref(HostedZoneName))) else: print("Redirecting root domain to www.") aliases = [Join("", ["www.", Ref(HostedZoneName)])] bucket_website_conf = WebsiteConfiguration( RedirectAllRequestsTo=RedirectAllRequestsTo( Protocol='http', HostName=Join( "", ["www.", Ref(HostedZoneName)]))) www_bucket_website_conf = WebsiteConfiguration( IndexDocument=config["index_document"], ErrorDocument=config["error_document"])
env = sys.argv[1] COMPONENT_NAME = "YaegarBooksWeb" t = Template(COMPONENT_NAME) t.add_version("2010-09-09") t.add_description(COMPONENT_NAME + " stacks for env " + env) s3bucket = t.add_resource( Bucket( "S3BucketForWebsiteContent", AccessControl=PublicRead, WebsiteConfiguration=WebsiteConfiguration( IndexDocument="index.html", ErrorDocument="error.html" ) ) ) t.add_output([ Output( "WebsiteURL", Value=GetAtt(s3bucket, "WebsiteURL"), Description="URL for website hosted on S3" ), Output( "S3BucketSecureURL", Value=Join("", ["http://", GetAtt(s3bucket, "DomainName")]), Description="Name of S3 bucket to hold website content" )
Default='spunt.be', )) rewrite_assets_lambda_code_key = template.add_parameter(Parameter( 'RewriteAssets', Type=constants.STRING, Default='lambda-code/frontend/rewrite_assets.zip', )) template.add_parameter_to_group(rewrite_assets_lambda_code_key, 'Lambda Keys') frontend_bucket = template.add_resource(Bucket( "FrontendBucket", AccessControl='PublicRead', # Maybe remove this later on WebsiteConfiguration=WebsiteConfiguration( IndexDocument='index.html', ErrorDocument='index.html', ), )) cloudfront_certificate = template.add_resource(Certificate( "CloudFrontCertificate", DomainName=Ref(domain_name), DomainValidationOptions=[DomainValidationOption( DomainName=Ref(domain_name), ValidationDomain=ImportValue(Join('-', [Ref(dns_stack), 'HostedZoneName'])), )], ValidationMethod='DNS', )) readonly_function_role = template.add_resource(Role( 'ReadonlyLambdaRole',
"websiteendpoint": "s3-website-sa-east-1.amazonaws.com" } }) hostedzone = t.add_parameter( Parameter( "HostedZone", Description="The DNS name of an existing Amazon Route 53 hosted zone", Type="String", )) root_bucket = t.add_resource( Bucket("RootBucket", BucketName=Ref(hostedzone), AccessControl=PublicRead, WebsiteConfiguration=WebsiteConfiguration( IndexDocument="index.html", ))) www_bucket = t.add_resource( Bucket("WWWBucket", BucketName=Join('.', ['www', Ref(hostedzone)]), AccessControl=PublicRead, WebsiteConfiguration=WebsiteConfiguration( RedirectAllRequestsTo=RedirectAllRequestsTo( HostName=Ref(root_bucket))))) record = t.add_resource( RecordSetGroup( 'RecordSetGroup', HostedZoneName=Join("", [Ref(hostedzone), "."]), RecordSets=[ RecordSet(Name=Ref(hostedzone), Type='A',