Using a CloudFront Distribution with an Amazon S3 Bucket
 Note
Note: The following beta artifacts are available to support CDN in ThingWorx Software Content Management deployments. These artifacts are available for early access, but are not yet supported:
  • Java SDK—Edge thing shapes with CDN support
  • ThingWorx Software Content Management edge thing shape
  • Amazon S3 extension
A method to push files to Amazon S3 can be used which allows you to distribute the files using CloudFront from there. This method involves more setup, but has added benefits. CloudFront talks directly to the S3 bucket, and there is only a one-time cost for uploading the file to S3 for the ThingWorx server even if the CDN cache misses.
Create an Amazon S3 Bucket
Complete the following steps to create the S3 bucket you want to use in your AWS console.
  1. Navigate to the S3 control panel and click Create Bucket.
  2. Enter a unique name for your bucket and a region appropriate to where your ThingWorx server resides
     Note
    You will need to remember these when creating an S3 respository thing within ThingWorx.
     
    Image
Create an IAM User for the S3 Bucket
ThingWorx requires credentials to talk to the AWS APIs and interact with the S3 bucket. Rather than using your top-level AWS credentials, or another existing user, it is recommended that you create a new IAM user within your account that has read and write access to the S3 bucket you created.
  1. Navigate to the IAM control panel within the AWS console.
  2. Create a new user. Be sure to generate and save the access keys, as you will need them when setting up the S3 repository thing in ThingWorx.
  3. In the Permissions tab, expand the Inline Policies section and click the link to create a new in-line policy.
  4. Since the policy you are creating is simple, directly create it using the Custom Policy editor.
  5. Allow all S3 actions scoped to your bucket in the following format: arn:aws:s3:::example-twx-bucket,arn:aws:s3:::example-twx-bucket/*, substituting your bucket name in place of example-twx-bucket.
    Image
Create an S3 File Repository Thing in ThingWorx
  1. From ThingWorx Composer, import the S3 File Repository extension. This provides the TWX.UTL.S3FileRepository thing template.
  2. Create a new thing with a unique name, and apply the TWX.UTL.S3FileRepository thing template.
    Image
  3. Under Entity Information, click Configuration.
  4. Enter the appropriate information for the region, bucket name, and credentials. This information is based on the bucket and user that were created earlier.
    Image
  5. Click Save. The S3 thing can now write and read from your configured S3 bucket. Later, you will use this as the cache repository when you configure CDN in Software Content Management.
Create a CloudFront Distribution with an S3 Bucket as an Origin
Create a web distribution similar to the one in Configuring CDN with Amazon CloudFront. However, with this distribution, the S3 bucket will be the origin, and CloudFront only has read access to bucket.
  1. Log in to your AWS console and navigate to the CloudFront control panel. For more information, see https://aws.amazon.com/documentation/.
  2. Create a new CloudFront Web Distribution.
  3. Enter the S3 bucket URL in the Origin Domain Name field. For example, bucketname.s3.amazonaws.com.
    Image
  4. Select Yes forRestrict Bucket Access. This prompts you to create a new user with read only permissions or use an existing user. For this example the Create a New Identity option is used and CloudFront will create a new user.
     Note
    If you select Create a New Identity, it is recommended that you also select Yes for the Grand Read Permissions on Bucket option.
     
  5. The remaining settings can be left as the defaults.
  6. Click Create Distribution.
  7. Your CDN URL Prefix for Software Content Management should look like the following example: https://d335myeqaba1rh.cloudfront.net/{0}.
  8. Select the S3 repository thing as the Cache Repository.
  9. Click Save.