aws-solutions / smart-product-solution

The Smart Product Solution is a customer deployable reference architecture to help manufacturers to jumpstart development of innovative connected/smart product services.
Apache License 2.0
28 stars 19 forks source link

OwnerApp does not update on deployment #13

Open billkidwell opened 4 years ago

billkidwell commented 4 years ago

It appears that the Owner WebApp is set to be cached in CloudFront (as expected), but there is no mechanism to circumvent caching when a new deployment is created. Perhaps I need to bump the version of the solution for this to take place.

My own research indicates that this can be accomplished by setting index.html to be uncached.

This article recommends the use of aws s3 sync as follows:

aws s3 sync --cache-control 'max-age=604800' --exclude index.html build/ s3://mywebsitebucket/
aws s3 sync --cache-control 'no-cache' build/ s3://mywebsitebucket/

I believe these updates would be part of the update in the postbuild step, if that is the correct approach.

For reference, the current post build is:

post_build:
    commands:
        - echo "Copying S3 assets to /$BUILD_OUTPUT_BUCKET/$SOLUTION_NAME/$VERSION"
        - aws s3 cp ./global-s3-assets/ s3://$BUILD_OUTPUT_BUCKET/$SOLUTION_NAME/$VERSION/ --recursive --acl bucket-owner-full-control
        - aws s3 cp ./regional-s3-assets/ s3://$BUILD_OUTPUT_BUCKET/$SOLUTION_NAME/$VERSION/ --recursive --acl bucket-owner-full-control
        - echo "Copying assets to output bucket complete `date`"

I am happy to attempt the changes if this is the right approach, but I'd rather have some input on it.

billkidwell commented 4 years ago

It appears I was incorrect about the post_build step. That is to get the assets in the output bucket, and the changes mentioned above are for putting it in the distribution bucket.

This is done via CDK. However, It does not appear that subsequent runs of the codepipline are updating the owner app in the bucket.

billkidwell commented 4 years ago

I don't know where this belongs in the process, but these statements updated my product owner webapp

aws s3 sync --cache-control 'max-age=604800' --exclude index.html s3://smart-fan-devoutputbucket-1f5bkjob6sxdm/smart-product-solution/v0.0.2/console s3://smartproductsolutionstac-smartproductownerwebappw-1lh59cyzvxeaa/
aws s3 sync --cache-control 'no-cache' s3://smart-fan-devoutputbucket-1f5bkjob6sxdm/smart-product-solution/v0.0.2/console s3://smartproductsolutionstac-smartproductownerwebappw-1lh59cyzvxeaa/
gsingh04 commented 4 years ago

Hello,

Can you try to bump the version number of the deployed stack by using the parameter section, as mentioned here

Please let us know if this resolves the issue for you.

billkidwell commented 4 years ago

Thanks for the suggestion. I did bump the version number in one of my attempts. I can try it again to be sure I was not making multiple changes. I'll review the doc again for that suggestion and make the change.

billkidwell commented 4 years ago

I bumped the stack version and I still see the issue. Here are the specific steps, in case that helps.

1) Make a cosmetic change to the owner web app source/console/src/views/Devices.jsx

          <Row>
            <Col md={12}>
              <Card
-                title={title}
+                title={title + " plus changes"}
                content={
                  <div>
                    <Col md={4}>

Verify the change locally by running npm start

2) Bump the version of the owner app

This was not mentioned as required, but seemed like good practice.

source/console/package.json

{
  "name": "aws-smart-product",
-  "version": "1.1.1",
+ "version": "1.1.2",
  "private": true,
  "dependencies": {
    "aws-amplify": "^1.2.4",

3) Bump the solution stack version

deployment/custom-deployment/cdk-manifest.json

{
    "default": {
-        "version": "v0.0.2",
+        "version": "v0.0.3",

Commit the changes. Push the changes.

Validate that CodePipeline detects the changes. Validate the solution stack version is correct in build

[Container] 2020/06/15 11:09:30 Running command echo "Deployment version $VERSION"
--
335 | Deployment version v0.0.3

Verify the version number in the deployment step...


SmartProductOwnerWebAppCopyS3Assets27AEC5DE:
--
320 | Type: Custom::CopyS3Assets
321 | Properties:
322 | ServiceToken:
323 | Fn::GetAtt:
324 | - SingletonLambdahelperFunction069AB33D
325 | - Arn
326 | Region:
327 | Ref: AWS::Region
328 | ManifestKey: smart-product-solution/v0.0.3/site-manifest.json
329 | SourceS3Bucket: smart-fan-devoutputbucket-1f5bkjob6sxdm
330 | SourceS3key: smart-product-solution/v0.0.3/console
331 | DestS3Bucket:
332 | Ref: SmartProductOwnerWebAppWebsiteBucketFD64D2DA
333 | DependsOn:
334 | - SmartProductOwnerWebAppHelperS3Policy0AFA4848
335 | UpdateReplacePolicy: Delete
336 | DeletionPolicy: Delete
337 | Metadata:
338 | aws:cdk:path: SmartProductSolutionStack/SmartProductOwnerWebApp/CopyS3Assets/Default

Expected Results: Change shows in the Owner Web App

Actual Results: The changes do not appear in the Owner Web App