DEV Community

Cover image for Angular Build Upload to AWS S3 + Cloudfront
Avinash Dalvi
Avinash Dalvi

Posted on

Angular Build Upload to AWS S3 + Cloudfront

Published Python automated script for Angular project deployment to AWS S3 and Cloudfront.

This will help to automated uploading Angular project build code to AWS S3 and CloudFront cached invalidation part. This will ensure to take backup of existing code for rollback operation if required.

from deployment_angular_s3_cloudfront import *

from constants import REQUEST_PARAMS

import argparse

parser = argparse.ArgumentParser()
parser.add_argument('--env', help="Select Environment PROD/STAGE/DEV")
parser.add_argument('--codepath', help="Code path of UI code")
parser.add_argument('--buildpath', help="Build path of UI code")
args = parser.parse_args()
if args.env:
    env = args.env
else:
    env = "STAGE"
if args.codepath:
    code_path = args.codepath
else:
    code_path = REQUEST_PARAMS.get(env).get('repositoryPath')

if args.buildpath:
    build_path = args.buildpath
else:
    build_path = REQUEST_PARAMS.get(env).get('buildPath')

print("Starting process for %s environment" %env)
request = {
    'bucketName': REQUEST_PARAMS.get(env).get('bucketName'), 
    'buildPath': build_path,
    'repositoryPath': code_path,
    'envName':  env,  # 'DEV, STAGE,PROD'
    'distributionId': REQUEST_PARAMS.get(env).get('distributionId'),
    'portal': 'PROJECTNAME',
    'buildCommand': REQUEST_PARAMS.get(env).get('buildCommand')
}
obj = DeploymentService(request)
obj.start_process()
Enter fullscreen mode Exit fullscreen mode

Contribution for this repository is open. pip package process in progress.

https://github.com/aviboy2006/angular-build-upload-s3-cloudfront

Top comments (0)