revmischa / cloudcam

IP camera surveillance management system using AWS IoT with support for Axis cameras.
Other
73 stars 15 forks source link

Deployment issues #19

Open tahamatech opened 7 years ago

tahamatech commented 7 years ago

I was able to build the source code.

However, after running ./deploy_stack as in:

cd cloudformation && ./deploy-stack.sh

I get some errors like:

ERROR: missing configuration variable: STACK_NAME ERROR: missing configuration variable: S3_CODE_BUCKET .. ..

How am I supposed to set these variables?

revmischa commented 7 years ago

Those are up to you to set as environment variables. See https://github.com/revmischa/cloudcam/blob/master/cloudformation/deploy-stack-dev.sh Depending on your AWS setup

tahamatech commented 7 years ago

Few questions:

STACK_NAME: what does it relate to? S3_CODE_BUCKET: this can be any AWS bucket accessible with my IAM user S3_UI_BUCKET: this can be another AWS bucket accessible with my IAM user CLOUDFRONT_UI_DISTRIBUTION_ID: this will be my cloud front ID, understood JANUS_KMS_KEY_USER: what is this? JANUS_HEALTH_CHECK_ALARMS_TOPIC: what is this?

More info:

I started a new AWS server on Ubuntu stack, and deployed JANAS server there, and ran the demos also (they dont work 100% but the to and fro communication between the demos on different browsers in different PCs show at-least there is something in place and hopefully working).

I was assuming setting up a new janas server will get the the JANAS_KMS_KEY_USER and HEALTH_CHECK_ALARMS_TOPIC somehow, but that is not the case.

How do I set above variables?

revmischa commented 7 years ago

They're environment variables - see https://github.com/revmischa/cloudcam/blob/master/cloudformation/deploy-stack-dev.sh

JANUS_KMS_KEY_USER=cloudcam-ops   # user which is granted permission to encrypt Janus SSL key via encrypt-ssl-key.sh
JANUS_HEALTH_CHECK_ALARMS_TOPIC=JanusHealthCheckAlarms   # topic for janus gateway health check alarms

the topic is a SNS topic i assume

tahamatech commented 7 years ago

I set these variables, according to my understanding, now I get new set of errors:


[user@localhost cloudformation]$ ./deploy-stack.sh 
make_bucket: my-s3-bucket-name

[Errno 2] No such file or directory: u'DIR/cloudcam-packaged.yml'

Invalid template path /home/user/cloudcam/cloudformation/cloudcam-packaged.yml
arn:aws:sns:us-east-1:540005654000:someSnsTopic:32cc7473-5085-495c-bb57-b4cebdead66e
./deploy-stack.sh: line 53: webpack: command not found

The user-provided path /../dev-ui/webroot does not exist.
{
    "Invalidation": {
        "Status": "InProgress", 
        "InvalidationBatch": {
            "Paths": {
                "Items": [
                    "/*"
                ], 
                "Quantity": 1
            }, 
            "CallerReference": "cli-1509631595-851972"
        }, 
        "Id": "IN6AAAAXE5G9U", 
        "CreateTime": "2017-11-02T14:06:41.975Z"
    }, 
    "Location": "https://cloudfront.amazonaws.com/2017-03-25/distribution/E2FSRZ1F75Y4IP/invalidation/IN6AAAAXE5G9U"
}
[user@localhost cloudformation]$ 

Any idea how to go around this?

someone--else commented 7 years ago

Should be fixed in https://github.com/revmischa/cloudcam/pull/20 There are also a couple of new env vars to set in deploy-stack-*.sh:

(those are only useful for adding/removing Janus Lightsail instances programmatically via janus_scale_lightsail lambda; we should probably add a configuration option for a static Janus instance list instead for cases where they are hosted elsewhere)

tahamatech commented 7 years ago

I moved forward, but now I get this error:

An error occurred (ValidationError) when calling the CreateChangeSet operation: Invalid input for parameter key JanusCertPem. Cannot specify usePreviousValue as true for a parameter key not in the previous template
UI URL:
arn:aws:sns:us-east-1:541155654472:jAAAAAASnsTopic:32cc7473-5085-495c-bb57-b4ceddddd66e

full log:

[user@localhost cloudformation]$ ./deploy-stack.sh
make_bucket: mybucket-s3

Successfully packaged artifacts and wrote output template to file /home/user/cloudcam/cloudformation/cloudcam-packaged.yml.
Execute the following command to deploy the packaged template
aws cloudformation deploy --template-file /home/user/cloudcam/cloudformation/cloudcam-packaged.yml --stack-name <YOUR STACK NAME>

An error occurred (ValidationError) when calling the CreateChangeSet operation: Invalid input for parameter key JanusCertPem. Cannot specify usePreviousValue as true for a parameter key not in the previous template
UI URL:
arn:aws:sns:us-east-1:541155654472:jAAAAAASnsTopic:32cc7473-5085-495c-bb57-b4ceddddd66e
./deploy-stack.sh: line 58: webpack: command not found
upload: ../dev-ui/webroot/favicon.ico to s3://mybucket-s3-ui/favicon.ico
upload: ../dev-ui/webroot/style.css to s3://mybucket-s3-ui/style.css
upload: ../dev-ui/webroot/icon.svg to s3://mybucket-s3-ui/icon.svg
upload: ../dev-ui/webroot/index.html to s3://mybucket-s3-ui/index.html
upload: ../dev-ui/webroot/janus.nojquery.js to s3://mybucket-s3-ui/janus.nojquery.js
{
    "Invalidation": {
        "Status": "InProgress", 
        "InvalidationBatch": {
            "Paths": {
                "Items": [
                    "/*"
                ], 
                "Quantity": 1
            }, 
            "CallerReference": "cli-1509964711-577450"
        }, 
        "Id": "I1E0QDYOB2TEXY", 
        "CreateTime": "2017-11-06T10:38:33.554Z"
    }, 
    "Location": "https://cloudfront.amazonaws.com/2017-03-25/distribution/E31S0ZAIA957BC/invalidation/I1E0QDYOB2TEXY"
}
[user@localhost cloudformation]$ 
tahamatech commented 7 years ago

Updates:

in cloudcam.yml file, I can see this:

Parameters:
  UiBucketName:
    Type: String
    Description: 'S3 UI bucket name. Must be the same as the UI domain name for CNAME redirect to work'
  JanusCertPem:
    Type: String
    Description: 'Janus gateway SSL cert PEM'
    Default: ''
  JanusCertKey:
    Type: String
    Description: 'Janus gateway SSL cert KEY'
    Default: ''

JanusCertPem and JanusCertKey are both blank, resulting in blank entries when cloudcam-packaged.yml is created.

Question: how do i set JanusCertPem and JanusCertKey ?

tahamatech commented 7 years ago

Also, what does:

./deploy-stack.sh: line 58: webpack: command not found

mean?

tahamatech commented 7 years ago

Update: so I installed webpack, using similar command:

npm install webpack -g

then I run ./deploy-stack.sh again, this time I get this:

[user@localhost cloudformation]$ ./deploy-stack.sh 
make_bucket: mybucket-s3

Successfully packaged artifacts and wrote output template to file /home/user/cloudcam/cloudformation/cloudcam-packaged.yml.
Execute the following command to deploy the packaged template
aws cloudformation deploy --template-file /home/user/cloudcam/cloudformation/cloudcam-packaged.yml --stack-name <YOUR STACK NAME>

An error occurred (ValidationError) when calling the CreateChangeSet operation: Invalid input for parameter key JanusCertPem. Cannot specify usePreviousValue as true for a parameter key not in the previous template
UI URL:
arn:aws:sns:us-east-1:541155654472:janwarSnsTopic:32cc7473-5085-495c-bb57-b4cebdead66e
/home/user/cloudcam/dev-ui/webpack.config.babel.js:1
(function (exports, require, module, __filename, __dirname) { import { DefinePlugin, optimize } from 'webpack'
                                                              ^^^^^^

SyntaxError: Unexpected token import
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at requireConfig (/usr/lib/node_modules/webpack/bin/convert-argv.js:97:18)
upload: ../dev-ui/webroot/style.css to s3://webrtc-xyzname.com/style.css
upload: ../dev-ui/webroot/index.html to s3://webrtc-xyzname.com/index.html
upload: ../dev-ui/webroot/favicon.ico to s3://webrtc-xyzname.com/favicon.ico
upload: ../dev-ui/webroot/index_old.html to s3://webrtc-xyzname.com/index_old.html
upload: ../dev-ui/webroot/janus.nojquery_old.js to s3://webrtc-xyzname.com/janus.nojquery_old.js
upload: ../dev-ui/webroot/janus.nojquery.js to s3://webrtc-xyzname.com/janus.nojquery.js
upload: ../dev-ui/webroot/icon.svg to s3://webrtc-xyzname.com/icon.svg
{
    "Invalidation": {
        "Status": "InProgress", 
        "InvalidationBatch": {
            "Paths": {
                "Items": [
                    "/*"
                ], 
                "Quantity": 1
            }, 
            "CallerReference": "cli-1510051176-466808"
        }, 
        "Id": "I2U4LTHY119DWJ", 
        "CreateTime": "2017-11-07T10:39:42.581Z"
    }, 
    "Location": "https://cloudfront.amazonaws.com/2017-03-25/distribution/E2STD5QKTLDI92/invalidation/I2U4LTHY119DWJ"
}
[user@localhost cloudformation]$ 

Any further pointers? Seems like never ending efforts here.

someone--else commented 7 years ago

Apologies for late reply

JanusCertPem/JanusCertKey aren't currently used for anything and are be removed in https://github.com/revmischa/cloudcam/pull/20, so CloudFormation ValidationError should go away

As for SyntaxError: Unexpected token import, I'm not seeing that in our environment; what webpack version do you have?

someone--else commented 7 years ago

Also, #21 fixes the dev-ui/.env file generation, so creating the Cloudformation stack from scratch should now work properly

tahamatech commented 7 years ago

As for SyntaxError: Unexpected token import, I'm not seeing that in our environment; what webpack version do you have?

It's:

[user@localhost ~]$ webpack --version
3.8.1
[user@localhost ~]$ 

Also, #21 fixes the dev-ui/.env file generation, so creating the Cloudformation stack from scratch should now work properly

This time I just downloaded whole cloudcam project again and 'make' it and run ./deploy-stack.sh, this time I get different error:


[user@localhost cloudformation]$ ./deploy-stack.sh 
make_bucket: janwar-s3
Uploading to 5f2abf8656b8c0d6d3cb450ed060e3e5  897965 / 897965.0  (100.00%)
Successfully packaged artifacts and wrote output template to file /home/user/cloudcam/cloudformation/cloudcam-packaged.yml.
Execute the following command to deploy the packaged template
aws cloudformation deploy --template-file /home/user/cloudcam/cloudformation/cloudcam-packaged.yml --stack-name <YOUR STACK NAME>

An error occurred (ValidationError) when calling the CreateChangeSet operation: Invalid input for parameter key LightsailBlueprintId. Cannot specify usePreviousValue as true for a parameter key not in the previous template
UI URL:
arn:aws:sns:us-east-1:541155654472:janwarSnsTopic:32cc7473-5085-495c-bb57-b4cebdead66e
/home/user/cloudcam/dev-ui/webpack.config.babel.js:1
(function (exports, require, module, __filename, __dirname) { import { DefinePlugin, optimize } from 'webpack'
                                                              ^^^^^^

SyntaxError: Unexpected token import
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at requireConfig (/usr/lib/node_modules/webpack/bin/convert-argv.js:97:18)
upload: ../dev-ui/webroot/style.css to s3://webrtc-mybucket.com/style.css
upload: ../dev-ui/webroot/index.html to s3://webrtc-mybucket.com/index.html
upload: ../dev-ui/webroot/favicon.ico to s3://webrtc-mybucket.com/favicon.ico
upload: ../dev-ui/webroot/icon.svg to s3://webrtc-mybucket.com/icon.svg
upload: ../dev-ui/webroot/janus.nojquery.js to s3://webrtc-mybucket.com/janus.nojquery.js
{
    "Invalidation": {
        "Status": "InProgress", 
        "InvalidationBatch": {
            "Paths": {
                "Items": [
                    "/*"
                ], 
                "Quantity": 1
            }, 
            "CallerReference": "cli-1510218639-970803"
        }, 
        "Id": "IG9JAQ6LTOZNB", 
        "CreateTime": "2017-11-09T09:10:41.090Z"
    }, 
    "Location": "https://cloudfront.amazonaws.com/2017-03-25/distribution/E2STD5QKTLDI92/invalidation/IG9JAQ6LTOZNB"
}
[user@localhost cloudformation]$ 

but I can see this variable 'LightsailBlueprintId' is set to default in cloudcam.yml:


  LightsailBlueprintId:
    Type: String
    Description: 'Lightsail Janus gateway instance blueprint (image) id'
    Default: amazon_linux_2017_03_1_1