Skip to content

[Feature Design] Copilot Static Site pattern #4621

@iamhopaul123

Description

@iamhopaul123

New service type “Static Site”

We’ll create a new service type called “Static Site”. And then we’ll have the following commands for it.

  • svc init
  • svc package
  • svc deploy
  • svc ls/show/status/logs (operational commands)
$ copilot svc init

  Which service type best represents your service's architecture?  [Use arrows to move, type to filter, ? for more help]
  > Request-Driven Web Service  (App Runner)
    Load Balanced Web Service   (Internet to ECS on Fargate)
    Backend Service             (ECS on Fargate)
    Worker Service              (Events to SQS to ECS on Fargate)
    Static Site.                (S3 bucket)

Upload experience

Users can specify what files to be uploaded in their service manifests. For example:

name: blob
type: Static Site

files:
  - source: ./foo # Required
    destination: /code # Optional default is "/"
    # Optional, whether the sub dir will be visited. By default it is false.
    recursive: true 
    # by default, *all files are included*. 
    # This means that providing *only* an --include filter will not change what files are transferred.
    # --include will only re-include files that have been excluded from an --exclude filter. 
    # If you only want to upload files with a particular extension, you need to first exclude all files,
    # then re-include the files with the particular extension.
    reinclude: *.jpg
    exclude: *
  - context: ./frontend # Optional. Context for this upload.
    source: dist # will be resolved as ./frontend/dist 
    destination: /dist

Integrate with CloudFront

The experience will be mostly the same as Copilot CloudFront Integration. In env manifest, users could specify the “cdn” field to connect CF with the S3 bucket.

cdn:
  static:
    alias: example.com # Required
    path: static # Default is *
    location: blob # Required

Note that, behind the scene we’ll add proper bucket policy so that it can be accessed by the CloudFront access identity.

Operational commands

svc ls

Users can use copilot svc ls to list all the created static pattern in a certain application

$ copilot svc ls

Name                Type
----                ----
blob                Static Site
frontend            Load Balanced Web Service

svc show

svc show shows the configuration of the static pattern:

$ copilot svc show

About

  Application  demo
  Name         blob
  Type         Static Site

Routes

  Environment  Ingress      URL
  -----------  -------      ---
  test         cloudfront   https://example.com/assets
  
Object Tree

  ├── backend
  │   └── manifest.yml
  ├── environments
  │   ├── dev
  │   │   └── manifest.yml
  │   ├── prod
  │   │   └── manifest.yml
  │   ├── staging
  │   │   └── manifest.yml
  │   └── test
  │       └── manifest.yml
  ├── pipeline.yml
  ├── pipelines
  │   ├── aws-copilot-sample-service-master
  │   │   ├── buildspec.yml
  │   │   └── manifest.yml
  │   └── fdsa
  │       ├── buildspec.yml
  │       └── manifest.yml
  └── worker
      └── manifest.yml

svc status

svc status shows the status of the static pattern. Specifically for s3 bucket, we’ll show

$ copilot svc status

Service Name: blob
Type: Static Site

Bucket Summary

  Total Size   Total Objects
  ----------   -------------
  585 KB       16

svc logs

svc logs allow Copilot users to be able to view the Amazon S3 Logs. For example:

$ copilot svc logs

Static Pattern: blob

79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be demo-test-blob [06/Feb/2019:00:00:38 +0000] 192.0.2.3 79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be 3E57427F3EXAMPLE REST.GET.VERSIONING - "GET /awsexamplebucket1?versioning HTTP/1.1" 200 - 113 - 7 - "-" "S3Console/0.4" - s9lzHYrFp76ZVxRcpX9+5cjAnEH2ROuNkd2BHfIa6UkFVdtjf5mKR3/eTPFvsiP/XV/VLi31234= SigV2 ECDHE-RSA-AES128-GCM-SHA256 AuthHeader awsexamplebucket1.s3.us-west-1.amazonaws.com TLSV1.1
79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be demo-test-blob [06/Feb/2019:00:00:38 +0000] 192.0.2.3 79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be 891CE47D2EXAMPLE REST.GET.LOGGING_STATUS - "GET /awsexamplebucket1?logging HTTP/1.1" 200 - 242 - 11 - "-" "S3Console/0.4" - 9vKBE6vMhrNiWHZmb2L0mXOcqPGzQOI5XLnCtZNPxev+Hf+7tpT6sxDwDty4LHBUOZJG96N1234= SigV2 ECDHE-RSA-AES128-GCM-SHA256 AuthHeader awsexamplebucket1.s3.us-west-1.amazonaws.com TLSV1.1
79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be demo-test-blob [06/Feb/2019:00:00:38 +0000] 192.0.2.3 79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be A1206F460EXAMPLE REST.GET.BUCKETPOLICY - "GET /awsexamplebucket1?policy HTTP/1.1" 404 NoSuchBucketPolicy 297 - 38 - "-" "S3Console/0.4" - BNaBsXZQQDbssi6xMBdBU2sLt+Yf5kZDmeBUP35sFoKa3sLLeMC78iwEIWxs99CRUrbS4n11234= SigV2 ECDHE-RSA-AES128-GCM-SHA256 AuthHeader awsexamplebucket1.s3.us-west-1.amazonaws.com TLSV1.1
79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be demo-test-blob [06/Feb/2019:00:01:00 +0000] 192.0.2.3 79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be 7B4A0FABBEXAMPLE REST.GET.VERSIONING - "GET /awsexamplebucket1?versioning HTTP/1.1" 200 - 113 - 33 - "-" "S3Console/0.4" - Ke1bUcazaN1jWuUlPJaxF64cQVpUEhoZKEG/hmy/gijN/I1DeWqDfFvnpybfEseEME/u7ME1234= SigV2 ECDHE-RSA-AES128-GCM-SHA256 AuthHeader awsexamplebucket1.s3.us-west-1.amazonaws.com TLSV1.1
79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be demo-test-blob [06/Feb/2019:00:01:57 +0000] 192.0.2.3 79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be DD6CC733AEXAMPLE REST.PUT.OBJECT s3-dg.pdf "PUT /awsexamplebucket1/s3-dg.pdf HTTP/1.1" 200 - - 4406583 41754 28 "-" "S3Console/0.4" - 10S62Zv81kBW7BB6SX4XJ48o6kpcl6LPwEoizZQQxJd5qDSCTLX0TgS37kYUBKQW3+bPdrg1234= SigV4 ECDHE-RSA-AES128-SHA AuthHeader awsexamplebucket1.s3.us-west-1.amazonaws.com TLSV1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/designIssues that are design proposals.type/featureIssues that are new feature requests.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions