Commit 44ac98a1 authored by Lee Brown's avatar Lee Brown

fix gitlab ci yaml

parent 931795a7
......@@ -34,7 +34,7 @@ cache:
.deploy_tmpl: &deploy_tmpl
<<: *job_tmpl
script:
- 'devops deploy -service=${SERVICE} -project=${PROJECT_NAME} -env=${TARGET_ENV} -enable_https=${ENABLE_HTTPS} -enable_elb=${ENABLE_ELB} -primary_host=${PRIMARY_HOST} -host_names=${HOST_NAMES} -private_bucket=${S3_BUCKET_PRIVATE} -public_bucket=${S3_BUCKET_PUBLIC} -static_files_s3={STATIC_FILES_S3_ENABLED} -static_files_cloudfront={STATIC_FILES_CLOUDFRONT_ENABLED} -static_files_img_resize={STATIC_FILES_IMG_RESIZE_ENABLED}'
- 'devops deploy -service=${SERVICE} -project=${PROJECT_NAME} -env=${TARGET_ENV} -enable_https=${ENABLE_HTTPS} -enable_elb=${ENABLE_ELB} -primary_host=${PRIMARY_HOST} -host_names=${HOST_NAMES} -private_bucket=${S3_BUCKET_PRIVATE} -public_bucket=${S3_BUCKET_PUBLIC} -public_bucket_cloudfront=${S3_BUCKET_PUBLIC_CLOUDFRONT} -static_files_s3=${STATIC_FILES_S3} -static_files_img_resize=${STATIC_FILES_IMG_RESIZE}'
.migrate_tmpl: &migrate_tmpl
<<: *job_tmpl
......@@ -88,9 +88,9 @@ webapp:deploy:dev:
HOST_NAMES: 'www.eproc.tech, dev.eproc.tech'
S3_BUCKET_PRIVATE: 'saas-starter-kit-private'
S3_BUCKET_PUBLIC: 'saas-starter-kit-public'
STATIC_FILES_S3_ENABLED: 'true'
STATIC_FILES_CLOUDFRONT_ENABLED: 'false'
STATIC_FILES_IMG_RESIZE_ENABLED: 'true'
S3_BUCKET_PUBLIC_CLOUDFRONT: 'false'
STATIC_FILES_S3: 'true'
STATIC_FILES_IMG_RESIZE: 'true'
AWS_USE_ROLE: 'true'
webapi:build:dev:
......@@ -127,9 +127,9 @@ webapi:deploy:dev:
HOST_NAMES: 'api.dev.eproc.tech'
S3_BUCKET_PRIVATE: 'saas-starter-kit-private'
S3_BUCKET_PUBLIC: 'saas-starter-kit-public'
STATIC_FILES_S3_ENABLED: 'false'
STATIC_FILES_CLOUDFRONT_ENABLED: 'false'
STATIC_FILES_IMG_RESIZE_ENABLED: 'false'
S3_BUCKET_PUBLIC_CLOUDFRONT: 'false'
STATIC_FILES_S3: 'false'
STATIC_FILES_IMG_RESIZE: 'false'
AWS_USE_ROLE: 'true'
#ddlogscollector:deploy:stage:
......
......@@ -157,7 +157,6 @@ func releaseTag(env, serviceName string) string {
return releaseTag
}
// releaseImage returns the name used for tagging a release image will always include one with environment and
// service name. If the env var CI_COMMIT_REF_NAME is set, it will be appended.
func releaseImage(env, serviceName, repositoryUri string) string {
......
......@@ -7,6 +7,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"github.com/aws/aws-sdk-go/service/cloudfront"
"io/ioutil"
"log"
"net/url"
......@@ -53,11 +54,12 @@ type ServiceDeployFlags struct {
Env string `validate:"oneof=dev stage prod" example:"dev"`
// Optional flags.
EnableHTTPS bool `validate:"omitempty" example:"false"`
ServiceHostPrimary string `validate:"omitempty" example:"example-project.com"`
ServiceHostNames cli.StringSlice `validate:"omitempty" example:"subdomain.example-project.com"`
S3BucketPrivateName string `validate:"omitempty" example:"saas-example-project-private"`
S3BucketPublicName string `validate:"omitempty" example:"saas-example-project-public"`
EnableHTTPS bool `validate:"omitempty" example:"false"`
ServiceHostPrimary string `validate:"omitempty" example:"example-project.com"`
ServiceHostNames cli.StringSlice `validate:"omitempty" example:"subdomain.example-project.com"`
S3BucketPrivateName string `validate:"omitempty" example:"saas-example-project-private"`
S3BucketPublicName string `validate:"omitempty" example:"saas-example-project-public"`
S3BucketPublicCloudfront bool `validate:"omitempty" example:"false"`
ProjectRoot string `validate:"omitempty" example:"."`
ProjectName string ` validate:"omitempty" example:"example-project"`
......@@ -65,9 +67,8 @@ type ServiceDeployFlags struct {
EnableLambdaVPC bool `validate:"omitempty" example:"false"`
EnableEcsElb bool `validate:"omitempty" example:"false"`
StaticFilesS3Enable bool `validate:"omitempty" example:"false"`
StaticFilesCloudfrontEnable bool `validate:"omitempty" example:"false"`
StaticFilesImgResizeEnable bool `validate:"omitempty" example:"false"`
StaticFilesS3Enable bool `validate:"omitempty" example:"false"`
StaticFilesImgResizeEnable bool `validate:"omitempty" example:"false"`
RecreateService bool `validate:"omitempty" example:"false"`
}
......@@ -116,10 +117,11 @@ type serviceDeployRequest struct {
S3BucketPublicKeyPrefix string `validate:"omitempty"`
S3Buckets []S3Bucket
StaticFilesS3Enable bool `validate:"omitempty"`
StaticFilesS3Prefix string `validate:"omitempty"`
StaticFilesCloudfrontEnable bool `validate:"omitempty"`
StaticFilesImgResizeEnable bool `validate:"omitempty"`
CloudfrontPublic *cloudfront.DistributionConfig
StaticFilesS3Enable bool `validate:"omitempty"`
StaticFilesS3Prefix string `validate:"omitempty"`
StaticFilesImgResizeEnable bool `validate:"omitempty"`
EnableEcsElb bool `validate:"omitempty"`
ElbLoadBalancerName string `validate:"omitempty"`
......@@ -184,15 +186,15 @@ func NewServiceDeployRequest(log *log.Logger, flags ServiceDeployFlags) (*servic
ServiceHostPrimary: flags.ServiceHostPrimary,
ServiceHostNames: flags.ServiceHostNames,
StaticFilesS3Enable: flags.StaticFilesS3Enable,
StaticFilesCloudfrontEnable: flags.StaticFilesCloudfrontEnable,
StaticFilesImgResizeEnable: flags.StaticFilesImgResizeEnable,
StaticFilesS3Enable: flags.StaticFilesS3Enable,
StaticFilesImgResizeEnable: flags.StaticFilesImgResizeEnable,
S3BucketPrivateName: flags.S3BucketPrivateName,
S3BucketPublicName: flags.S3BucketPublicName,
EnableLambdaVPC: flags.EnableLambdaVPC,
EnableEcsElb: flags.EnableEcsElb,
RecreateService: flags.RecreateService,
EnableLambdaVPC: flags.EnableLambdaVPC,
EnableEcsElb: flags.EnableEcsElb,
RecreateService: flags.RecreateService,
flags: flags,
}
......@@ -279,6 +281,71 @@ func NewServiceDeployRequest(log *log.Logger, flags ServiceDeployFlags) (*servic
},
},
})
/*if flags.S3BucketPublicCloudfront {
req.CloudfrontPublic = &cloudfront.DistributionConfig{
Comment: aws.String(""),
Enabled: aws.Bool(true),
HttpVersion: aws.String( "http2"),
IsIPV6Enabled: aws.Bool(true),
// A complex type that describes the default cache behavior if you don't specify
// a CacheBehavior element or if files don't match any of the values of PathPattern
// in CacheBehavior elements. You must create exactly one default cache behavior.
//
// DefaultCacheBehavior is a required field
DefaultCacheBehavior: &cloudfront.DefaultCacheBehavior{
// ......................................
},
// A complex type that contains information about origins for this distribution.
//
// Origins is a required field
Origins: &cloudfront.Origins{
// ......................................
},
// A complex type that specifies whether you want viewers to use HTTP or HTTPS
// to request your objects, whether you're using an alternate domain name with
// HTTPS, and if so, if you're using AWS Certificate Manager (ACM) or a third-party
// certificate authority.
ViewerCertificate: &cloudfront.ViewerCertificate{
// ......................................
},
// The price class that corresponds with the maximum price that you want to
// pay for CloudFront service. If you specify PriceClass_All, CloudFront responds
// to requests for your objects from all CloudFront edge locations.
//
// If you specify a price class other than PriceClass_All, CloudFront serves
// your objects from the CloudFront edge location that has the lowest latency
// among the edge locations in your price class. Viewers who are in or near
// regions that are excluded from your specified price class may encounter slower
// performance.
//
// For more information about price classes, see Choosing the Price Class for
// a CloudFront Distribution (https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PriceClass.html)
// in the Amazon CloudFront Developer Guide. For information about CloudFront
// pricing, including how price classes (such as Price Class 100) map to CloudFront
// regions, see Amazon CloudFront Pricing (http://aws.amazon.com/cloudfront/pricing/).
// For price class information, scroll down to see the table at the bottom of
// the page.
PriceClass: aws.String("PriceClass_All"),
// A unique value (for example, a date-time stamp) that ensures that the request
// can't be replayed.
//
// If the value of CallerReference is new (regardless of the content of the
// DistributionConfig object), CloudFront creates a new distribution.
//
// If CallerReference is a value that you already sent in a previous request
// to create a distribution, CloudFront returns a DistributionAlreadyExists
// error.
//
// CallerReference is a required field
CallerReference: aws.String("devops-deploy"),
}
}*/
}
// The private S3 Bucket used to persist data for services.
......@@ -678,7 +745,7 @@ func NewServiceDeployRequest(log *log.Logger, flags ServiceDeployFlags) (*servic
// A unique string that identifies the request and that allows failed CreatePrivateDnsNamespace
// requests to be retried without the risk of executing the operation twice.
// CreatorRequestId can be any unique string, for example, a date/time stamp.
CreatorRequestId: aws.String("truss-deploy"),
CreatorRequestId: aws.String("devops-deploy"),
}
// Service Discovery Service settings.
......@@ -725,7 +792,7 @@ func NewServiceDeployRequest(log *log.Logger, flags ServiceDeployFlags) (*servic
// A unique string that identifies the request and that allows failed CreatePrivateDnsNamespace
// requests to be retried without the risk of executing the operation twice.
// CreatorRequestId can be any unique string, for example, a date/time stamp.
CreatorRequestId: aws.String("truss-deploy"),
CreatorRequestId: aws.String("devops-deploy"),
}
// Elastic Cache settings for a Redis cache cluster. Could defined different settings by env.
......@@ -1642,7 +1709,7 @@ func ServiceDeploy(log *log.Logger, req *serviceDeployRequest) error {
// stamp.
//
// CallerReference is a required field
CallerReference: aws.String("truss-deploy"),
CallerReference: aws.String("devops-deploy"),
})
if err != nil {
return errors.Wrapf(err, "Failed to create route 53 hosted zone '%s' for domain '%s'", zoneName, dn)
......@@ -2395,7 +2462,7 @@ func ServiceDeploy(log *log.Logger, req *serviceDeployRequest) error {
}
// Static files served from CloudFront.
if req.StaticFilesCloudfrontEnable {
if req.CloudfrontPublic != nil {
placeholders["{STATIC_FILES_CLOUDFRONT_ENABLED}"] = "true"
}
......
......@@ -77,13 +77,13 @@ func main() {
cli.StringSliceFlag{Name: "host_names", Usage: "dev, stage, or prod", Value: &deployFlags.ServiceHostNames},
cli.StringFlag{Name: "private_bucket", Usage: "dev, stage, or prod", Destination: &deployFlags.S3BucketPrivateName},
cli.StringFlag{Name: "public_bucket", Usage: "dev, stage, or prod", Destination: &deployFlags.S3BucketPublicName},
cli.BoolFlag{Name: "public_bucket_cloudfront", Usage: "serve static files from Cloudfront", Destination: &deployFlags.S3BucketPublicCloudfront},
cli.StringFlag{Name: "dockerfile", Usage: "DockerFile for service", Destination: &deployFlags.DockerFile},
cli.StringFlag{Name: "root", Usage: "project root directory", Destination: &deployFlags.ProjectRoot},
cli.StringFlag{Name: "project", Usage: "name of project", Destination: &deployFlags.ProjectName},
cli.BoolFlag{Name: "enable_elb", Usage: "enable deployed to use Elastic Load Balancer", Destination: &deployFlags.EnableEcsElb},
cli.BoolTFlag{Name: "lambda_vpc", Usage: "deploy lambda behind VPC", Destination: &deployFlags.EnableLambdaVPC},
cli.BoolFlag{Name: "static_files_s3", Usage: "service static files from S3", Destination: &deployFlags.StaticFilesS3Enable},
cli.BoolFlag{Name: "static_files_cloudfront", Usage: "serve static files from Cloudfront", Destination: &deployFlags.StaticFilesCloudfrontEnable},
cli.BoolFlag{Name: "static_files_img_resize", Usage: "enable response images from service", Destination: &deployFlags.StaticFilesImgResizeEnable},
cli.BoolFlag{Name: "recreate_service", Usage: "skip docker push after build", Destination: &deployFlags.RecreateService},
},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment