Errors occur in the following conditions.
Running on local server (ubuntu on windows).
I deployed these files.
Token is minted.
The yaml file is generated via Django.
The generated file is then used to run the API request formatter to generate Json.
Template:
code:
(marmalade.ledger.sale
(read-msg 'token-id)
(read-msg 'account)
(read-decimal 'amount)
(read-integer 'timeout)
)
data:
token-id: "${token_id}"
account: "${account}"
amount: ${amount}
timeout: ${timeout}
quote:
price: "${price}"
recipient-guard:
keys:
[ "${recipient_key}", ]
recipient: ${recipient}
keyPairs:
- public: ${marmalade_pub}
secret: ${marmalade_sec}
caps:
- name: "marmalade.ledger.SALE"
args: ["${token_id}", "${account}", ${amount}, ${timeout}]
Generated File:
code:
(marmalade.ledger.sale
(read-msg 'token-id)
(read-msg 'account)
(read-decimal 'amount)
(read-integer 'timeout)
)
data:
token-id: "92496e13-4414-4c58-aceb-0c7d77120af2"
account: "a0fc037522ae0202052775f773e3cf823e3bd7640a12e80694b2dd76"
amount: 1.0
timeout: 100
quote:
price: "1.0"
recipient-guard:
keys:
[ "52d9d996e6cc77f48a1ff1b734224a2ce6cee3af84c3f6e1720047645e9c2c31", ]
recipient: a0fc037522ae0202052775f773e3cf823e3bd7640a12e80694b2dd76
keyPairs:
- public: b63680e667576818b713d5d398ad395610b522fbc53e08afe46a719a0a128fb5
secret: 4242d66fac539660702ce4f9c01a39bb16f1d6b6c7110c6647010cb4dd041dd8
caps:
- name: "marmalade.ledger.SALE"
args: ["92496e13-4414-4c58-aceb-0c7d77120af2", "a0fc037522ae0202052775f773e3cf823e3bd7640a12e80694b2dd76", 1.0, 100]
JSON:
b'{"cmds":[{"hash":"cD5gqQVmRj08xqOdqfKwLLL2eb76_j_eZDdzV4Xdkjg","sigs":[{"sig":"2fb4bbb496271a138c33a4c8b94cf4511c8ad494b5c0cca94a2d1f98a37025e865b1414116fe77e841fbe71c6430e
5da72209123a63e958b992f4e8ba1770103"}],"cmd":"{\\"networkId\\":null,\\"payload\\":{\\"exec\\":{\\"data\\":{\\"amount\\":1.0,\\"token-id\\":\\"92496e13-4414-4c58-aceb-0c7d7712
0af2\\",\\"account\\":\\"a0fc037522ae0202052775f773e3cf823e3bd7640a12e80694b2dd76\\",\\"quote\\":{\\"recipient-guard\\":{\\"keys\\":[\\"52d9d996e6cc77f48a1ff1b734224a2ce6cee3
af84c3f6e1720047645e9c2c31\\"]},\\"price\\":\\"1.0\\",\\"recipient\\":\\"a0fc037522ae0202052775f773e3cf823e3bd7640a12e80694b2dd76\\"},\\"timeout\\":100},\\"code\\":\\"(marmal
ade.ledger.sale (read-msg \'token-id) (read-msg \'account) (read-decimal
\'amount) (read-integer \'timeout)
)\\"}},\\"signers\\":[{\\"pubKey\\":\\"b63680e667576818b713d5d398a
d395610b522fbc53e08afe46a719a0a128fb5\\",\\"clist\\":[{\\"args\\":[\\"92496e13-4414-4c58-aceb-0c7d77120af2\\",\\"a0fc037522ae0202052775f773e3cf823e3bd7640a12e80694b2dd76\\",1
,100],\\"name\\":\\"marmalade.ledger.SALE\\"}]}],\\"meta\\":{\\"creationTime\\":0,\\"ttl\\":0,\\"gasLimit\\":0,\\"chainId\\":\\"\\",\\"gasPrice\\":0,\\"sender\\":\\"\\"},\\"n
once\\":\\"2022-07-20 09:53:05.975872 UTC\\"}"}]}\n'
The following error occurred when I posted the Json data to request.post on 'localhost:8080/api/v1/poll'.
{'cD5gqQVmRj08xqOdqfKwLLL2eb76_j_eZDdzV4Xdkjg': {'gas': 0, 'result': {'status': 'failure', 'error': {'callStack': [], 'type': 'EvalError', 'message': 'Managed capability not installed: (marmalade.ledger.OFFER "92496e13-4414-4c58-aceb-0c7d77120af2" "a0fc037522ae0202052775f773e3cf823e3bd7640a12e80694b2dd76" 1.0 100)', 'info': ''}}, 'reqKey': 'cD5gqQVmRj08xqOdqfKwLLL2eb76_j_eZDdzV4Xdkjg', 'logs': None, 'metaData': None,
'continuation': None, 'txId': None}}
How do I get these to work properly?
P.S. I am Japanese and not an English speaker. I used a translation site to ask this question. Sorry if the description is missing.
Related
I have a Type: AWS::Serverless::HttpApi which I am trying to connect to a Type: AWS::Serverless::StateMachine as a trigger. Meaning the HTTP API would trigger the Step Function state machine.
I can get it working, by only specifying a single input. For example, the DefinitionBody when it works, looks like this:
DefinitionBody:
info:
version: '1.0'
title:
Ref: AWS::StackName
paths:
"/github/secret":
post:
responses:
default:
description: "Default response for POST /"
x-amazon-apigateway-integration:
integrationSubtype: "StepFunctions-StartExecution"
credentials:
Fn::GetAtt: [StepFunctionsApiRole, Arn]
requestParameters:
Input: $request.body
StateMachineArn: !Ref SecretScannerStateMachine
payloadFormatVersion: "1.0"
type: "aws_proxy"
connectionType: "INTERNET"
timeoutInMillis: 30000
openapi: 3.0.1
x-amazon-apigateway-importexport-version: "1.0"
Take note of the following line: Input: $request.body. I am only specifying the $request.body.
However, I need to be able to send the $request.body and $request.header.X-Hub-Signature-256. I need to send BOTH these values to my state machine as an input.
I have tried so many different ways. For example:
Input: " { body: $request.body, header: $request.header.X-Hub-Signature-256 }"
and
$request.body
$request.header.X-Hub-Signature-256
and
Input: $request
I get different errors each time, but this is the main one:
Warnings found during import: Unable to create integration for resource at path 'POST /github/secret': Invalid selection expression specified: Validation Result: warnings : [], errors : [Invalid source: $request specified for destination: Input].
Any help on how to pass multiple values would so be appreciated.
I am trying to implement the below calls:
POST https://host/sessions
DELETE https://host/sessions/{session_id}
The POST call is to establish a session, the DELETE call is to log out an established session.
So, in the YAML file, how to have an empty base path? It's currently a slash in the YAML file as it's a required filed, but the slash is redundant. Any idea? Thanks.
swagger: '2.0'
info:
version: '0.0.1'
title: authenticate
#description: To be provided
# #termsOfService:To be provided
contact:
name: test
basePath: /sessions
paths:
/:
post:
summary: eatablish a session
description: sessions is a collection.This POST creates a new session in the sessions collection and the name of the session returned by this command is the session token.
consumes:
- "application/json"
parameters:
- in: header
name: user_name
type: string
required: true
- in: header
name: password
type: string
required: true
responses:
200:
description: establish a session successfully
400:
$ref: "#/responses/BadRequest"
500:
description: unexpected error
schema:
$ref: '#/definitions/errorModel'
/{session_id}:
delete:
summary: log out
description: use sessionid to log out an established session.
produces:
- application/json
parameters:
- in: path
name: session_id
type: string
required: true
responses:
200:
description: log out a session successfully
400:
$ref: "#/responses/BadRequest"
500:
description: unexpected error
schema:
$ref: '#/definitions/errorModel'
Swagger defines
A relative path to an individual endpoint. The field name MUST begin with a forward slash (/).
Therefore, the slash is required and you can't have an empty path.
I'm trying to create a cloud SQL instance by deployment API, when I try to create it directly from YAML file it is created successfully ,meanwhile when I create the instance from jinja/python file I get an error as below:
code: RESOURCE_ERROR
location: /deployments/olpr/resources/test
message: '{"ResourceType":"sqladmin.v1beta4.instance","ResourceErrorCode":"400","ResourceErrorMessage":{"code":400,"message":"Request
contains an invalid argument.","status":"INVALID_ARGUMENT","statusMessage":"Bad
Request","requestPath":"https://www.googleapis.com/sql/v1beta4/projects/project_id/instances","httpMethod":"POST"}}'
Is there any way where I can see the invalid_argument so that I can fix it.
Please help me with some valid suggestions.
The resource as below:
*resources = [
{
'name': 'test',
'type': 'sqladmin.v1beta4.instance',
'properties': {
'zone': 'europe-west1-b',
'rootPassword': '1234567' ,
'instanceType': 'CLOUD_SQL_INSTANCE',
'databaseVersion': 'SQLSERVER_2017_EXPRESS',
'backendType': 'SECOND_GEN',
'settings':{
'machineType' : 'db-custom-1-3840',
'dataDiskSizeGb': 10,
'dataDiskType': 'PD_SSD',
'ipConfiguration': {
'ipv4Enabled': False,
'privateNetwork':'projects/project_id/global/networks/project_id-vpc'
}
}
}
}
]*
**
**Yaml file:
resources:
- name: he
type: sqladmin.v1beta4.instance
properties:
region: europe-west1
zone: europe-west1-b
backendType: SECOND_GEN
instanceType: CLOUD_SQL_INSTANCE
databaseVersion: SQLSERVER_2017_EXPRESS
serviceAccountEmailAddress: user#project_id.iam.gserviceaccount.com
rootPassword: mypass
settings:
dataDiskSizeGb: 10
dataDiskType: PD_SSD
ipConfiguration:
ipv4Enabled: false
privateNetwork: vpc
kind: sql#settings
machineType: db-custom-1-3840**
**
You're not supplying a region in the Python version. Try adding `'region': 'europe-west1' to the properties.
I am having issues deploying a lambda with a handler in a nested directory using sam.
I perform the following steps:
package:
sam package --template template.yaml --output-template-file packaged.yaml --s3-bucket
Creates a packaged.yaml that I use in the next step.
deploy:
aws cloudformation deploy --template-file /Users/localuser/Do/learn-sam/dynamo-stream-lambda/packaged.yaml --stack-name barkingstack
ERROR
Failed to create the changeset: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILED. Reason: Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [PublishNewBark] is invalid. Missing required property 'Handler'.
Cloudformation/SAM Template
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Globals:
Function:
Runtime: nodejs8.10
Timeout: 300
Resources:
PublishNewBark:
Type: AWS::Serverless::Function
FunctionName: publishNewBark
CodeUri: .
Handler: src/index.handler
Role: "<ROLE_ARN>"
Description: Reads from the DynamoDB Stream and publishes to an SNS topic
Events:
- ReceiveBark:
Type: DynamoDB
Stream: !GetAtt BarkTable.StreamArn
StartingPosition: TRIM_HORIZON
BatchSize: 1
BarkTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: BarkTable
KeySchema:
- KeyType: HASH
AttributeName: id
AttributeDefinitions:
- AttributeName: id
AttributeType: S
StreamSpecification:
StreamViewType: NEW_AND_OLD_IMAGES
ProvisionedThroughput:
WriteCapacityUnits: 5
ReadCapacityUnits: 5
WooferTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: wooferTopic
TopicName: wooferTopic
Subscription:
- Endpoint: <my_email>
Protocol: email
DIRECTORY STRUCTURE
root_directory/
events/ (for sample events)
policies/ (for IAM Role to be created for the lambda using CLI)
src/index.js
package.json
node_modules
template.yaml
HANDLER CODE
async function handler (event, context) {
console.log(JSON.stringify(event, null, 2))
return {}
}
module.exports = {handler}
I believe you have to put everything except the resource type under "Properties".
Your function declaration should be:
PublishNewBark:
Type: AWS::Serverless::Function
Properties:
FunctionName: publishNewBark
CodeUri: .
Handler: src/index.handler
Role: "<ROLE_ARN>"
Description: Reads from the DynamoDB Stream and publishes to an SNS topic
Events:
- ReceiveBark:
Type: DynamoDB
Stream: !GetAtt BarkTable.StreamArn
StartingPosition: TRIM_HORIZON
BatchSize: 1
I face issue with my swagger file :
swagger: '2.0'
paths:
/currencies:
get:
responses:
'200':
description: ''
summary: 'list currencies summary'
x-auth-type: None
x-throttling-tier: Unlimited
produces:
- application/json
description: 'list currencies description'
'/currencies/{currencieId}':
get:
responses:
'200':
description: ''
description: 'Single currency description'
parameters:
- name: currencieId
in: path
allowMultiple: false
required: true
type: string
description: 'paramter description'
summary: 'Single currency'
x-auth-type: None
x-throttling-tier: Unlimited
produces:
- application/json
info:
title: MDM
version: v1
Here is my issue :
✖ Swagger Error
Not a valid parameter definition
Jump to line 20
Details
Object
code: "ONE_OF_MISSING"
params: Array [0]
message: "Not a valid parameter definition"
path: Array [5]
0: "paths"
1: "/currencies/{currencieId}"
2: "get"
3: "parameters"
4: "0"
schemaId: "http://swagger.io/v2/schema.json#"
inner: Array [2]
level: 900
type: "Swagger Error"
description: "Not a valid parameter definition"
lineNumber: 20
Issue in swagger editor
I am a bit lost with that ....
Thanks for your help.
Julien
Remove allowMultiple: false from the definition of the currencieId parameter. That eliminates the error.
The allowMultiple keyword does not exist in the OpenAPI (fka Swagger) Specification 2.0. It was used in v1.2, but in 2.0 it was replaced with type: array and collectionFormat.
allowMultiple: false is not correct