The Wayback Machine - https://web.archive.org/web/20220106115359/https://repost.aws/
By using AWS re:Post, you agree to the Terms of Use

Welcome to AWS re:Post

re:Post gives you access to a vibrant community that helps you become even more successful on AWS

Learn AWS faster by following popular topics

see all
1/18

Recent questions

see all
1/18

Passing custom senderID and templateID for AWS SNS in India using NodeJS

So, I am trying to figure out the NodeJS Code for sending SMS to Indian mobile numbers using AWS SNS. I have gotten the code down to sending the SMS but I am not able to map the senderID or the templateID which I have gotten registered. The DLT Template ID has been registered with Airtel DLT Connect and even the entityID has been registered there. I am getting the SMS but with a random senderID, not the one I am assigning. The code snippet is below: ``` var AWS = require('aws-sdk'); var config = { AWS: { accessKeyId: "", secretAccessKey: "", region: "ap-south-1" } } AWS.config.update({ accessKeyId: config.AWS.accessKeyId, secretAccessKey: config.AWS.secretAccessKey, region: config.AWS.region }); var params = { Message: "Your verification code is 123345. This code is valid for 24 hours.", MessageStructure: 'string', PhoneNumber: '+91XXXXXXXXXX', MessageAttributes: { "AWS.SNS.SMS.SenderID": { DataType: 'String', StringValue: 'CustomSenderID' }, "AWS.SNS.SMS.SMSType": { DataType: 'String', StringValue: 'Transactional' }, "AWS.MM.SMS.EntityID": { DataType: 'String', StringValue: 'EntityID' }, "AWS.MM.SMS.TemplateId": { DataType: 'String', StringValue: 'TemplateID' } } }; var sns = new AWS.SNS(); sns.publish(params, function (err, data) { if (err) { console.log(err); } else { console.log(data); } }); ``` So, if I don't pass the EntityID and the templateID, I get the SMS but with a random numeric senderID. When I try to pass it in the example shown above, I get the below error: ``` ParameterValueInvalid: Message attribute names starting with 'AWS.' or 'Amazon.' are reserved for use by Amazon. at Request.extractError (D:\WORK\Agri10x\Development\Projects\dataserver\node_modules\aws-sdk\lib\protocol\query.js:50:29) at Request.callListeners (D:\WORK\Agri10x\Development\Projects\dataserver\node_modules\aws-sdk\lib\sequential_executor.js:106:20) at Request.emit (D:\WORK\Agri10x\Development\Projects\dataserver\node_modules\aws-sdk\lib\sequential_executor.js:78:10) at Request.emit (D:\WORK\Agri10x\Development\Projects\dataserver\node_modules\aws-sdk\lib\request.js:686:14) at Request.transition (D:\WORK\Agri10x\Development\Projects\dataserver\node_modules\aws-sdk\lib\request.js:22:10) at AcceptorStateMachine.runTo (D:\WORK\Agri10x\Development\Projects\dataserver\node_modules\aws-sdk\lib\state_machine.js:14:12) at D:\WORK\Agri10x\Development\Projects\dataserver\node_modules\aws-sdk\lib\state_machine.js:26:10 at Request.<anonymous> (D:\WORK\Agri10x\Development\Projects\dataserver\node_modules\aws-sdk\lib\request.js:38:9) at Request.<anonymous> (D:\WORK\Agri10x\Development\Projects\dataserver\node_modules\aws-sdk\lib\request.js:688:12) at Request.callListeners (D:\WORK\Agri10x\Development\Projects\dataserver\node_modules\aws-sdk\lib\sequential_executor.js:116:18) { code: 'ParameterValueInvalid', time: 2022-01-06T09:33:30.590Z, requestId: 'dc92b0a1-e561-5ae4-a32d-eaf15ccb3fea', statusCode: 400, retryable: false, retryDelay: 57.53422286102854 } ``` Any help would be appreciated! Thanks in advance!
0
answers
0
votes
0
views
AWS-User-5677981
asked 2 hours ago

AWS Lambda Applications and NodeJS

I noticed that NodeJS is the only runtime option when creating an application. https://us-east-2.console.aws.amazon.com/lambda/home?region=us-east-2#/create/application/configure Is there a reason that NodeJS is the only option? I've heard that NodeJS is able to cold start faster than Java for lambdas. I also noticed the example Java lambda project defaults to 512MB MemorySize and NodeJS defaults to 128MB. Is Amazon trying to push us to NodeJS when building lambda applications because it's a better language for the environment? Is it possible to create a Java lambda resource within the template.yml of an application? Do I need to build the classfiles and upload them manually? The `java-test` folder in my project has this structure ``` java-test/src/main/java/example/Handler.java java-test/src/main/resources java-test/build.gradle ``` I've tried the following Resource configuration, but the example.Handler class cannot be found. ``` javaTest: Type: AWS::Serverless::Function Properties: CodeUri: java-test/ Handler: example.Handler Runtime: java11 Description: Java function MemorySize: 512 Timeout: 10 # Function's execution role Policies: - AWSLambdaBasicExecutionRole - AWSLambda_ReadOnlyAccess - AWSXrayWriteOnlyAccess - AWSLambdaVPCAccessExecutionRole Tracing: Active ``` I copied parts of the blank-java lambda project below. https://github.com/awsdocs/aws-lambda-developer-guide/tree/main/sample-apps/blank-java Here's the full build output ``` docker ps "C:\Program Files\Amazon\AWSSAMCLI\bin\sam.cmd" build javaTest --template C:\Users\bensi\IdeaProjects\team-up\template.yml --build-dir C:\Users\bensi\IdeaProjects\team-up\.aws-sam\build --use-container Starting Build inside a container Building codeuri: C:\Users\bensi\IdeaProjects\team-up\java-test runtime: java11 metadata: {} architecture: x86_64 functions: ['javaTest'] Fetching public.ecr.aws/sam/build-java11:latest-x86_64 Docker container image...... Mounting C:\Users\bensi\IdeaProjects\team-up\java-test as /tmp/samcli/source:ro,delegated inside runtime container Build Succeeded Built Artifacts : .aws-sam\build Built Template : .aws-sam\build\template.yaml Commands you can use next ========================= [*] Invoke Function: sam local invoke [*] Test Function in the Cloud: sam sync --stack-name {stack-name} --watch [*] Deploy: sam deploy --guided Running JavaGradleWorkflow:GradleBuild Running JavaGradleWorkflow:CopyArtifacts "C:\Program Files\Amazon\AWSSAMCLI\bin\sam.cmd" local invoke javaTest --template C:\Users\bensi\IdeaProjects\team-up\.aws-sam\build\template.yaml --event "C:\Users\bensi\AppData\Local\Temp\[Local] javaTest-event5.json" Invoking example.Handler (java11) Skip pulling image and use local one: public.ecr.aws/sam/emulation-java11:rapid-1.36.0-x86_64. Mounting C:\Users\bensi\IdeaProjects\team-up\.aws-sam\build\javaTest as /var/task:ro,delegated inside runtime container START RequestId: 3e9debb6-a640-4ba2-bd6e-5f2d818d303e Version: $LATEST {"errorMessage":"Class not found: example.Handler","errorType":"java.lang.ClassNotFoundException"}Class not found: example.Handler: java.lang.ClassNotFoundException java.lang.ClassNotFoundException: example.Handler. Current classpath: file:/var/task/:file:/var/task/lib/aws-lambda-java-core-1.2.1.jar:file:/var/task/lib/gson-2.8.6.jar END RequestId: 3e9debb6-a640-4ba2-bd6e-5f2d818d303e REPORT RequestId: 3e9debb6-a640-4ba2-bd6e-5f2d818d303e Init Duration: 0.07 ms Duration: 271.19 ms Billed Duration: 272 ms Memory Size: 512 MB Max Memory Used: 512 MB ```
1
answers
0
votes
3
views
AWS-User-1
asked 8 hours ago

aws-elasticbeanstalk-ec2-role aws-elasticbeanstalk-ec2-role is not authorized to perform: secretsmanager:GetSecretValue although the default role is updated to include policy

There is an EC2 instance attempting to get a secret from SecretsManager but errors with the following: ``` Error getting database credentials from Secrets Manager AccessDeniedException: User: arn:aws:sts::{AccountNumber}:assumed-role/aws-elasticbeanstalk-ec2-role/i-{instanceID} is not authorized to perform: secretsmanager:GetSecretValue on resource: rds/staging/secretName because no identity-based policy allows the secretsmanager:GetSecretValue action ``` I have tried adding the following policy to the general aws-elasticbeanstalk-ec2-role to allow for access but it is still not able to get the secrets: GetSecretsPolicy: ``` { "Version": "2012-10-17", "Statement": [ { "Sid": "VisualEditor0", "Effect": "Allow", "Action": [ "secretsmanager:GetResourcePolicy", "secretsmanager:GetSecretValue", "secretsmanager:DescribeSecret", "secretsmanager:ListSecretVersionIds" ], "Resource": "arn:aws:secretsmanager:*:{AccountNumber}:secret:rds/production/secretName" }, { "Sid": "VisualEditor1", "Effect": "Allow", "Action": "secretsmanager:GetRandomPassword", "Resource": "*" }, { "Sid": "VisualEditor2", "Effect": "Allow", "Action": [ "secretsmanager:GetResourcePolicy", "secretsmanager:GetSecretValue", "secretsmanager:DescribeSecret", "secretsmanager:ListSecretVersionIds" ], "Resource": "arn:aws:secretsmanager:*:{AccountNumber}:secret:rds/staging/secretName" } ] } ``` I continue to get the error and am wondering if there is something I can tweak to make it able to have proper access to the secret values
0
answers
0
votes
2
views
AWS-User-1866056
asked 11 hours ago