-
-
Save copernicus/638463 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from boto.cloudfront import CloudFrontConnection | |
def update_default_root_object(searched_origin, aws_access_key_id, aws_secret_access_key, default_root_object='index.html'): | |
""" sets default_root_object of an aws cloud front distribution | |
for futher information checkout http://boto.s3.amazonaws.com/ref/cloudfront.html | |
or http://github.com/boto/boto/tree/master/boto/cloudfront | |
""" | |
connection = CloudFrontConnection(aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key) | |
distro_summary = [distro_summary for distro_summary in connection.get_all_distributions() if distro_summary.origin == searched_origin][0] | |
distro = distro_summary.get_distribution() | |
distro.update(default_root_object=default_root_object) | |
print(connection.get_distribution_config(distro.id).to_xml()) | |
if __name__ == '__main__': | |
searched_origin = '<bucket_name>.s3.amazonaws.com' | |
aws_access_key_id = '<aws_access_key_id>' | |
aws_secret_access_key = '<aws_secret_access_key>' | |
update_default_root_object(searched_origin=searched_origin, | |
aws_access_key_id=aws_access_key_id, | |
aws_secret_access_key=aws_secret_access_key | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment