diff --git a/labs/gmt.md b/labs/gmt.md index a210275..fc2b44c 100644 --- a/labs/gmt.md +++ b/labs/gmt.md @@ -41,8 +41,13 @@ a model that looks similar to this one: ### Tasks - Open up GMT in the right hand side of the IDE + ![](img/open-GMT.png) - Create a new Service Template ![](img/GMT-add-model.png) + You may use whichever Namespace you want to store your + new service template (eg. "your_organization.servicetemplates") + or use the same as projected (eg. "example.org.tosca.servicetemplates") + Using your own Namespace you can keep all your service templates in the same place. - Give it a name (eg. "serverless-todo") and click add - Click on the Topology Template tab, and click @@ -96,7 +101,7 @@ properties: ``` displayName: "AwsApiGateway" properties: - api_title: "ServerlessToDoListAPI" + name: "ServerlessToDoListAPI" api_version: "1.0.0" api_description: "a simple serverless API example" ``` @@ -125,7 +130,7 @@ displayName: "GetTodoItem" properties: handler: "get.handler" name: "get-todo" - runtime: "nodejs10.x" + runtime: "nodejs12.x" statement_id: "get-stmt" zip_file: "1cea0130441318a22cee6904ea971a" env_vars: {"TODOS_TABLE":"items"} @@ -140,7 +145,7 @@ displayName: "CreateTodoItem" properties: handler: "create.handler" name: "create-item" - runtime: "nodejs10.x" + runtime: "nodejs12.x" statement_id: "create-stmt" zip_file: "36f24b63abeb3a7f70a1f1ca42077e" env_vars: {"TODOS_TABLE":"items"} @@ -154,9 +159,9 @@ properties: displayName: "ListTodoItem" properties: handler: "list.handler" - name: "list-todos" - runtime: "nodejs10.x" - statement_id: "list-statement" + name: "list-item" + runtime: "nodejs12.x" + statement_id: "list-stmt" zip_file: "9f9fd845ed2f3b061136179467ba5f" env_vars: {"TODOS_TABLE":"items"} ``` @@ -170,7 +175,7 @@ properties: properties: handler: "update.handler" name: "update-item" - runtime: "nodejs10.x" + runtime: "nodejs12.x" statement_id: "update-stmt" zip_file: "0b2516f89dbd44dc1bd03712e81db7" env_vars: {"TODOS_TABLE":"items"} @@ -185,7 +190,7 @@ properties: properties: handler: "delete.handler" name: "delete-item" - runtime: "nodejs10.x" + runtime: "nodejs12.x" statement_id: "delete-stmt" zip_file: "07714624b3dd0c78502024164411a7" env_vars: {"TODOS_TABLE":"items"} @@ -317,6 +322,8 @@ already been modelled in the service templates section called `ServerlessToDoListAPITestingExample`. +The TOSCA file of the above service template can be found [here](servicetemplates/ServiceTemplate.tosca) + ## Next step Head over to [xOpera](xopera.md) section to deploy diff --git a/labs/ide.md b/labs/ide.md index 688ff31..a789b94 100644 --- a/labs/ide.md +++ b/labs/ide.md @@ -49,7 +49,7 @@ mode): ![](img/IDE-layout.png) -Now you are ready to clone down the project code. +Now you are ready to clone down the project code. (Skip this step if you are using the pre-packaged source code from Function Hub) - Click terminal and `Open terminal in specific container` use the diff --git a/labs/img/application-GMT2.png b/labs/img/application-GMT2.png index 4af2a19..57750f8 100644 Binary files a/labs/img/application-GMT2.png and b/labs/img/application-GMT2.png differ diff --git a/labs/img/open-GMT.png b/labs/img/open-GMT.png new file mode 100644 index 0000000..36241e2 Binary files /dev/null and b/labs/img/open-GMT.png differ diff --git a/labs/servicetemplates/ServiceTemplate.tosca b/labs/servicetemplates/ServiceTemplate.tosca new file mode 100644 index 0000000..3f1619b --- /dev/null +++ b/labs/servicetemplates/ServiceTemplate.tosca @@ -0,0 +1,287 @@ +tosca_definitions_version: tosca_simple_yaml_1_3 + +metadata: + targetNamespace: "radon.blueprints.testing" +topology_template: + node_templates: + AwsLambdaFunction_1: + type: radon.nodes.aws.AwsLambdaFunction + metadata: + x: "893" + y: "113" + displayName: "GetTodoItem" + properties: + handler: "get.handler" + memory: 128 + name: "get-item" + runtime: "nodejs12.x" + alias: "dev" + statement_id: "get-stmt" + zip_file: { get_artifact: [ SELF, get_item ] } + timeout: 300 + env_vars: + TODOS_TABLE: "items" + requirements: + - endpoint: + node: AwsDynamoDBTable_0 + relationship: con_ConnectsTo_1 + capability: database_endpoint + - host: + node: AwsPlatform_0 + relationship: con_HostedOn_3 + capability: host + artifacts: + get_item: + type: radon.artifacts.archive.Zip + file: get.zip + AwsLambdaFunction_2: + type: radon.nodes.aws.AwsLambdaFunction + metadata: + x: "893" + y: "208" + displayName: "CreateTodoItem" + properties: + handler: "create.handler" + memory: 128 + name: "create-item" + runtime: "nodejs12.x" + alias: "dev" + statement_id: "create-stmt" + zip_file: { get_artifact: [ SELF, create_item ] } + timeout: 300 + env_vars: + TODOS_TABLE: "items" + requirements: + - endpoint: + node: AwsDynamoDBTable_0 + relationship: con_ConnectsTo_2 + capability: database_endpoint + - host: + node: AwsPlatform_0 + relationship: con_HostedOn_4 + capability: host + artifacts: + create_item: + type: radon.artifacts.archive.Zip + file: create.zip + AwsDynamoDBTable_0: + type: radon.nodes.aws.AwsDynamoDBTable + metadata: + x: "1514" + y: "301" + displayName: "ItemsTable" + properties: + hash_key_name: "id" + read_capacity: 1 + name: "items" + write_capacity: 1 + hash_key_type: "STRING" + requirements: + - host: + node: AwsPlatform_0 + relationship: con_HostedOn_0 + capability: host + AwsLambdaFunction_0: + type: radon.nodes.aws.AwsLambdaFunction + metadata: + x: "893" + y: "304" + displayName: "ListTodoItem" + properties: + handler: "list.handler" + memory: 128 + name: "list-item" + runtime: "nodejs12.x" + alias: "dev" + statement_id: "list-stmt" + zip_file: { get_artifact: [ SELF, list_items ] } + timeout: 300 + concurrency: 0 + env_vars: + TODOS_TABLE: "items" + requirements: + - endpoint: + node: AwsDynamoDBTable_0 + relationship: con_ConnectsTo_0 + capability: database_endpoint + - host: + node: AwsPlatform_0 + relationship: con_HostedOn_1 + capability: host + artifacts: + list_items: + type: radon.artifacts.archive.Zip + file: list.zip + AwsLambdaFunction_3: + type: radon.nodes.aws.AwsLambdaFunction + metadata: + x: "888" + y: "398" + displayName: "UpdateTodoItem" + properties: + handler: "update.handler" + memory: 128 + name: "update-item" + runtime: "nodejs12.x" + alias: "dev" + statement_id: "update-stmt" + zip_file: { get_artifact: [ SELF, update_item ] } + timeout: 300 + env_vars: + TODOS_TABLE: "items" + requirements: + - endpoint: + node: AwsDynamoDBTable_0 + relationship: con_ConnectsTo_3 + capability: database_endpoint + - host: + node: AwsPlatform_0 + relationship: con_HostedOn_5 + capability: host + artifacts: + update_item: + type: radon.artifacts.archive.Zip + file: update.zip + AwsPlatform_0: + type: radon.nodes.aws.AwsPlatform + metadata: + x: "549" + y: "589" + displayName: "AwsPlatform" + properties: + name: "AWS" + region: "eu-central-1" + AwsLambdaFunction_4: + type: radon.nodes.aws.AwsLambdaFunction + metadata: + x: "888" + y: "499" + displayName: "DeleteTodoItem" + properties: + handler: "delete.handler" + memory: 128 + name: "delete-item" + runtime: "nodejs12.x" + alias: "dev" + statement_id: "delete-stmt" + zip_file: { get_artifact: [ SELF, delete_item ] } + timeout: 300 + env_vars: + TODOS_TABLE: "items" + requirements: + - endpoint: + node: AwsDynamoDBTable_0 + relationship: con_ConnectsTo_4 + capability: database_endpoint + - host: + node: AwsPlatform_0 + relationship: con_HostedOn_6 + capability: host + artifacts: + delete_item: + type: radon.artifacts.archive.Zip + file: delete.zip + AwsApiGateway_0: + type: radon.nodes.aws.AwsApiGateway + metadata: + x: "355" + y: "300" + displayName: "AwsApiGateway" + properties: + name: "ServerlessToDoListAPI" + api_version: "1.0.0" + api_description: "a simple serverless API example" + requirements: + - host: + node: AwsPlatform_0 + relationship: con_HostedOn_2 + capability: host + - invoker: + node: AwsLambdaFunction_0 + relationship: con_AwsApiGatewayTriggers_0 + capability: invocable + - invoker: + node: AwsLambdaFunction_1 + relationship: con_AwsApiGatewayTriggers_1 + capability: invocable + - invoker: + node: AwsLambdaFunction_2 + relationship: con_AwsApiGatewayTriggers_2 + capability: invocable + - invoker: + node: AwsLambdaFunction_3 + relationship: con_AwsApiGatewayTriggers_3 + capability: invocable + - invoker: + node: AwsLambdaFunction_4 + relationship: con_AwsApiGatewayTriggers_4 + capability: invocable + relationship_templates: + con_HostedOn_2: + type: tosca.relationships.HostedOn + con_HostedOn_3: + type: tosca.relationships.HostedOn + con_HostedOn_0: + type: tosca.relationships.HostedOn + con_HostedOn_1: + type: tosca.relationships.HostedOn + con_HostedOn_6: + type: tosca.relationships.HostedOn + con_HostedOn_4: + type: tosca.relationships.HostedOn + con_HostedOn_5: + type: tosca.relationships.HostedOn + con_ConnectsTo_2: + type: radon.relationships.ConnectsTo + con_ConnectsTo_3: + type: radon.relationships.ConnectsTo + con_ConnectsTo_4: + type: radon.relationships.ConnectsTo + con_AwsApiGatewayTriggers_4: + type: radon.relationships.aws.AwsApiGatewayTriggers + properties: + endpoint: "/todos/{id}" + http_methods: "delete" + con_AwsApiGatewayTriggers_3: + type: radon.relationships.aws.AwsApiGatewayTriggers + properties: + endpoint: "/todos/{id}" + http_methods: "put" + con_ConnectsTo_0: + type: radon.relationships.ConnectsTo + con_AwsApiGatewayTriggers_2: + type: radon.relationships.aws.AwsApiGatewayTriggers + properties: + endpoint: "/todos" + http_methods: "post" + con_ConnectsTo_1: + type: radon.relationships.ConnectsTo + con_AwsApiGatewayTriggers_1: + type: radon.relationships.aws.AwsApiGatewayTriggers + properties: + endpoint: "/todos/{id}" + http_methods: "get" + con_AwsApiGatewayTriggers_0: + type: radon.relationships.aws.AwsApiGatewayTriggers + properties: + endpoint: "/todos" + http_methods: "get" + policies: + - exampleTestPolicy: + type: radon.policies.testing.HttpEndpointTest + properties: + path: "/" + hostname: "google.com" + method: "GET" + port: "443" + expected_status: "200" + ti_blueprint: "radon.blueprints.testing.DeploymentTestAgentEC2" + use_https: "true" + test_id: "exampleTest" + targets: [ AwsLambdaFunction_0 ] + outputs: + testing_endpoint: + type: string + description: Endpoint that is used for testing + required: false + default: { concat: [ { get_attribute: [ AwsApiGateway_0, endpoint_url ] }, { get_property: [ con_AwsApiGatewayTriggers_0, endpoint ] } ] }