Exemple #1
0
    def test_s3_bucket_accelerate_configuration(self):
        t = Template()
        ac = AccelerateConfiguration(AccelerationStatus="Enabled")

        b = Bucket("s3Bucket", AccelerateConfiguration=ac)
        t.add_resource(b)
        output = t.to_json()
        self.assertIn('"AccelerationStatus": "Enabled"', output)
from troposphere.s3 import AccelerateConfiguration, Bucket, PublicRead

t = Template()

t.set_description(
    "AWS CloudFormation Sample Template S3_Bucket: Sample template showing :"
    "How to create a publicly accessible S3 bucket. "
    "How to enable S3 Transfer Acceleration. "
    "**WARNING** This template creates an Amazon S3 Bucket. "
    "You will be billed for the AWS resources used if you create "
    "a stack from this template.")

s3bucket = t.add_resource(
    Bucket(
        "S3Bucket",
        # Make public Read
        AccessControl=PublicRead,
        # Enable s3 Transfer Acceleration
        AccelerateConfiguration=AccelerateConfiguration(
            AccelerationStatus="Enabled", ),
    ))

t.add_output(
    Output(
        "BucketName",
        Value=Ref(s3bucket),
        Description="Name of S3 bucket with s3 transfer acceleration enabled",
    ))

print(t.to_json())
Exemple #3
0
 def test_accelerate_configuration_invalid_value(self):
     with self.assertRaises(ValueError):
         AccelerateConfiguration(AccelerationStatus='Invalid Value')
Exemple #4
0
 def test_accelerate_configuration_suspended(self):
     ac = AccelerateConfiguration(
         AccelerationStatus='Suspended',
     )
     self.assertEqual('Suspended', ac.AccelerationStatus)
Exemple #5
0
 def test_accelerate_configuration_enabled(self):
     ac = AccelerateConfiguration(
         AccelerationStatus='Enabled',
     )
     self.assertEqual('Enabled', ac.AccelerationStatus)
Exemple #6
0
                            CorsConfiguration,
                            CorsRules)


BUCKET_NAME_SUFFIX = 'MockDatalake'
BUCKETS = [["LandingZone", "Raw"],
           ["WorkZone", "Partially Processed"],
           ["GoldZone", "Final Processed"]]

BUCKET_CORS_CONFIG = CorsConfiguration(CorsRules=[CorsRules(
    AllowedOrigins=["*"], AllowedMethods=["POST", "PUT", "HEAD", "GET"],
    AllowedHeaders=["*"],
)])

BUCKET_VERSIONING_CONFIG = VersioningConfiguration(Status="Enabled")
BUCKET_ACCELERATION_CONFIG = AccelerateConfiguration(
    AccelerationStatus="Enabled")


def init():
    load_dotenv(find_dotenv())


init()

DEBUG = os.getenv('DEBUG', False)

if not DEBUG:
    print('---------------------------------------------')
    print('Loading .env ....')
    print('Using VIRTUAL_ENV = ', os.getenv('VIRTUAL_ENV'))
    print('Successfully loaded .env')