Questions tagged with AWS Step Functions

Content language: English

Sort by most recent

Browse through the questions and answers listed below or filter and sort to narrow down your results.

lambda - redshift - status = Query does not exist

The same code works in one account but not another account. In a step function, lambda calls a redshift query, returns, next step calls get status. The lambda returns but the status call errors with msg "Query does not exist". The query in the previous step has successfully run and a statement id returned. Its only the step with status call that fails. Other lambdas in the same step function using the same pattern work correctly. These other steps use the same get status lambda as the steps that fail. The common item is the call to the redshift query in the previous step. When ever that is used the status call fails. However: The query executes correctly and the same lambda works in the same step function in another account. Other points: The redshift clusters were built with a cloud formation template and should be identical. The entire step function (unchanged other than account number change) works correctly in another account. The lambdas have been manually copied and pasted from the account that works to ensure they are identical. Does any one have any suggestions, as all obvious checks have been done. For completeness the code for the redshift query call is below, however as stated above this works in another account. ``` import json import boto3 import base64 import urllib.parse import botocore.session as bc from botocore.exceptions import ClientError ssm_client = boto3.client('ssm') def lambda_handler(event, context): environment = event['environment'] source_bucket = event['source_bucket'] processed_bucket = event['processed_bucket'] role = event['role'] region = event['region'] database_name = event['database_name'] secret_name = event['secret_name'] secret_arn = event['secret_arn'] cluster_id = event['cluster_id'] proc_name = event['proc_name'] ssm_redshift_proc_name = ssm_client.get_parameter(Name=proc_name, WithDecryption=True) redshift_proc_name = ssm_redshift_proc_name['Parameter']['Value'] query_str = "call "+redshift_proc_name+"();" bc_session = bc.get_session() session = boto3.Session( botocore_session = bc_session, region_name = region, ) client_redshift = session.client("redshift-data") res = client_redshift.execute_statement( Database = database_name, SecretArn = secret_arn, Sql = query_str, ClusterIdentifier = cluster_id ) return { 'environment': environment, 'source_bucket': source_bucket, 'processed_bucket': processed_bucket, 'role': role, 'region': region, 'database_name': database_name, 'secret_name': secret_name, 'secret_arn': secret_arn, 'cluster_id': cluster_id, 'statementid': res['Id'] } ```
1
answers
0
votes
35
views
asked 16 days ago
1
answers
0
votes
38
views
asked 22 days ago
1
answers
0
votes
37
views
asked a month ago

Step Machine - is there any kind of intrinsic functions for if statements?

I'm pretty new to Step Machines, I've created a relatively complex machine - which works quite well and is hooked up to API gateway. There's one piece of it which just feels a bit ugly to me, I've created this example but let me be clear that this is a "fake" example so explaining better ways of doing it via the API or whatever doesn't help much, I just want to achieve what I'm showing below but ideally in a neater way. I should also add what I've done works, but just isn't pretty. Basically I set a variable using the pass functions with two different outputs based on a choice, what it feels like I should be able to do is something LIKE; "S.$": "States.If($.resolution>1000,'Desktop','Mobile')" ![Enter image description here](/media/postImages/original/IM4POup_IbQXupGNm464K45Q) ``` { "Comment": "A description of my state machine", "StartAt": "Choice", "States": { "Choice": { "Type": "Choice", "Choices": [ { "Variable": "$.resolution", "NumericGreaterThan": 1000, "Next": "Status is OK" } ], "Default": "Status is Fail" }, "Status is OK": { "Type": "Pass", "Next": "DynamoDB PutItem", "Result": { "type": "Desktop" }, "ResultPath": "$.display" }, "Status is Fail": { "Type": "Pass", "Next": "DynamoDB PutItem", "Result": { "type": "Mobile" }, "ResultPath": "$.display" }, "DynamoDB PutItem": { "Type": "Task", "Resource": "arn:aws:states:::dynamodb:putItem", "Parameters": { "TableName": "MyDynamoDBTable", "Item": { "Name": { "S.$": "$.name" }, "DisplayType": { "S.$": "$.display.type" } } }, "End": true } } } ```
2
answers
0
votes
40
views
asked 2 months ago