I am using AWS lambda to process a csv file and send out a message in chime to my team on a daily basis. I need to make a part of the message a hyperlink.
Current output: ID: https://www.example.com/ID=123456
Required output: ID: 123456
and when one clicks on the ID, it should take the user to a link like "https://www.google.com/ID=123456"
I am using urllib3 to send the output from aws lambda to chime group. I believe chime only offers Markdown or code type formatting. I would like to know if it is possible to implement a solution in the aws lambda function itself.
Related
Need some help with Lambda invocation and authentication. I have an AWS Lambda function that is invoked from AWS IoT MQTT feed based on a specific topic. The invocation happens when an authenticated IoT Thing publishes to MQTT on that topic. My question is how do I see who has invoked it? I need this information so I know under what user to store the published information to database. I'm guessing there should be some environment variables that carry this information but I haven't found it. Maybe I been looking in all the wrong places:/
Many thanks,
Marcus
You should be able to modify the Lambda trigger in your IoT configuration to include the client ID by using something like the following SQL statement:
select clientId() as clientId, *
How are you?
You could send the user on the topic message. Is it not easier? Not sure how to get it from env var.
So I am using quick sight java SDK for integrating s3 with quicksight, and for that, I am using CreateDataSource.so while using this method, I have to pass one parameter in this method DataSourceId. The description of this parameter in the AWS documentation is like "An ID for the data source. This ID is unique per AWS Region for each AWS account," and I do not know how to get this.i to have to get this parameter programmatically. Type of this parameter is String
getClient().createDataSource(new CreateDataSourceRequest().withDataSourceId("DataSourceID").withAwsAccountId("AWS ACCOUNT").withName("display name of data soure").withType(DataSourceType.S3));
getClient is a client for using quicksight API
and yeah for the integration of s3 and quicksight I can not do this through AWS console I have to do this programmatically
I do not know how to get this.i to have to get this parameter programmatically
This is something that you set yourself, for example:
DataSourceId = "my-first-test-data-source-id"
I'm trying to use Go to send objects in a S3 bucket to Textract and collect the response.
I'm using the aws go sdk package and able to connect to my S3 bucket and list all the objects contained within. So far so good. I now need to be able to send one of those objects (a .pdf file) to Textract and collect the response(s).
The AWS Go SDK content for interacting with Textract seem to be quite extensive but I cannot find a good example for how to do this.
I would be very grateful for a sample or advice on how to do this.
To start a job, you invoke StartDocumentTextDetection, using a DocumentLocation to specify the file, and you specify a SNS topic where Textract will publish a notification when it has finished to process your job.
You have now two possibilities:
Subscribe to the SNS topic, and when you receive a message retrieve the result
Create a lambda function triggered by the SNS topic, which retrieves the result.
The second option is IMO better 'cause it use less computation time (doesn't run until the job hasn't finished).
To retrieve the job, you use GetDocumentTextDetection
If anyone else reaches this site searching for an answer:
I understood the documentation as if I could just call the StartDocumentAnalysis function through the textract SDK but in fact what was missing is the fact that you need to create a new Session first and do the calls based on the session:
https://docs.aws.amazon.com/sdk-for-go/api/service/textract/#New
I have setup a rule in cloudwatch to monitor Glue ETL. In the state change I am sending a notification to SNS. I have modified the input transformer to get a custom body of the email but not getting how to change the subject line of the email . It still giving the default "AWS Notification Message"
My Input transformer :
{"state":"$.detail.state"}
"The JOB has changed state to <state>."
Use a Lambda function—rather than the Amazon SNS topic—as a target for the CloudWatch Events rule. Then, configure the Lambda function to publish a custom message to the Amazon SNS topic when triggered by the CloudWatch Events rule.
Documented here: https://aws.amazon.com/premiumsupport/knowledge-center/change-sns-email-for-cloudwatch-events/
Transformer (no way Jose)
As far as I can tell there is currently no way to control the email subject with a transformer. Typically you will control the notification body for a rule through the transformer which modifies the input json message (e.g. in the case of a build https://docs.aws.amazon.com/codebuild/latest/userguide/sample-build-notifications.html#sample-build-notifications-ref ). Based on what I see in the documentation this only modifies part of the body embedded between the header and the footer of the email payload.
JSON (also not possible)
1. Since all notifications are generated with an API call with json payload you can experiment and configure. Using the CLI you can specify a json format using --message-structure attribute. However the subject is not part of the json payload itself and is sent as a separate parameter "--subject" (see example below) you won't be able to configure that unless they either modify the UI or the json payload.
2.In order to exercise greater control over your output you might have to use JSON (select "Constant (JSON text)") which is documented for mobile messaging https://docs.aws.amazon.com/sns/latest/dg/mobile-push-send-custommessage.html but not very well for HTTP https://docs.aws.amazon.com/sns/latest/dg/sns-message-and-json-formats.html but decent for the CLI https://docs.aws.amazon.com/cli/latest/reference/sns/publish.html
3. You can go to the console https://console.aws.amazon.com/sns/v2/ and click on "Publish a Message" which allows you to specify a subject. Notice that there is a "JSON message generator" but that's only for the body.
Coding Workaround (possible ...kinda)
If you feel really determined you can explore a workaround: look at the API and figure out what call is equivalent to sending a call which includes a subject. Create a lambda function that executes that call. From the rule invoke the lambda :-) and you are done. If there is will, there is a way...
Notes:
aws sns publish --topic-arn arn:aws:sns:us-east-1:652499160872:DP-Build --message-structure json --subject "Test Build subject" --message "{ \"default\":\"Foo\", \"email\":\"Bar\"}"
According to the docs there is a "Subject" key you can pass as a parameter:
Blockquote
Subject
The Subject parameter specified when the notification was published to the topic. Note that this is an optional parameter. If no Subject was specified, then this name/value pair does not appear in this JSON document.
Blockquote
set "detail-type":"Glue ETL State-change Notification"
you might need to look at https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/CloudWatch-Events-Input-Transformer-Tutorial.html
I'm using AWS SES service to send emails to my customers, I wonder if there's any solution available to attach files directly into my email using SES and Lambda functions. I did a research and ended up in finding solutions which recommends to include a link to S3 files, not attaching the file as it is. I want to attach files as it is from SE, which is downloadable from the email itself. Not a link or reference to the attachment.
As folks mentioned in the comments above, there's no way to automatically send a file "directly" from S3 via SES. It sounds like you will need to write a Lambda function which performs the following steps:
Fetch file object from S3 into memory
Build multi-part MIME message with text body and file attachment
Send your raw message through SES
Step 1 is a simple matter of using S3.getObject with the appropriate Bucket/Key parameters.
I do not know which language you are using, but in Node.js step #2 can be accomplished using the npm package mailcomposer like so:
const mailOptions = {
from: 'no-reply#example.tld',
to: 'whoever#example.tld',
subject: 'The Subject Line',
text: 'Body of message. File is attached...\n\n',
attachments: [
{
filename: 'file.txt',
content: fileData,
},
],
};
const mail = mailcomposer(mailOptions);
mail.build(<callback>);
Step 3 is again a simple matter of using SES.sendRawEmail with the RawMessage.Data parameter set to the message you built in step 2.
Nodemailer comes to mind.
There is a good medium tutorial covering how to do it here.