Open jeanbaptistepriez opened 3 years ago
Hey @jeanbaptistepriez π Thanks for raising this! This seems to be more of a CLI issue so I will transfer it over for you.
Hey @jeanbaptistepriez :wave: thanks for raising this! Unfortunately given the current implementation where notifications
are created via the AWS SDK and not CloudFormation, this is currently not possible out-of-the-box as we are unable reference the output. For that I will mark this as a feature-request.
As a workaround we can leverage environment variables or secrets with Lambda functions to manually input the notification's ID for consumption inside your Lambda. For reference, the ID's value is captured as an output in the amplify-meta.json
file.
Ok thanks for your answer. I found a workaround:
amplify/backend/amplify-meta.json
xxxxxxxx
for dev environment & yyyyyyyy
for prod one) in the amplify/team-provider-info.json
file:
{
"dev": {
...
"categories": {
...
"function": {
...
"maFunction": {
"pinpointId": "xxxxxxxx",
"deploymentBucketName" ...
...
Β Β }
}
Β }
},
"prod": {
...
"categories": {
...
"function": {
...
"maFunction": {
"pinpointId": "yyyyyyyyyy",
"deploymentBucketName" ...
...
Β Β }
}
Β }
}
}
pinpointId
as a parameter of the cloudformation templateamplify push
(+ amplify env checkout ...; amplify push
) works.Is it a "not so bad practices" or I risk to get some side effect ?
If it makes sense I suggest to you to enrich the documentation https://docs.amplify.aws/cli/usage/customcf#n3-optional-reference-existing-parameters to describe this ability to pass env specific parameters from outside of cloudformation
Hey @jeanbaptistepriez glad you were able to find a workaround.
Is it a "not so bad practices" or I risk to get some side effect ?
This value will be included in your stack's CloudFormation template.
I have a similar issue where I'm trying to configure a DynamoDB trigger to point to a lambda function in the respective dev
and prod
Amplify environments. Is this a sanctioned approach, @josefaidt? It seemed to work upon pushing to each of my environments. Is manually modifying team-provider-info.json
something the Amplify team expects or might this blow up in the future?
To expand on the solution from @jeanbaptistepriez...
Within my amplify/team-provider-info.json
:
"prod": {
"....": {},
"function": {
"myFunction": {
"deploymentBucketName": "amplify-...-deployment",
"s3Key": "amplify-builds/...-build.zip",
"dynamodbTransitStreamARN": "arn:aws:dynamodb:us-east-1:..."
}
}
}
And at the top of my amplify/function/myFunction/myFunction-cloudformation-template.json
:
"Parameters": {
"dynamodbAccountItemStreamARN": {
"Type": "String"
}
}
Hey @chancyk :wave: from the documentation page for Amplify files and folders it is not recommended to manually edit the team-provider-info.json
file. We may see these values are removed after performing additional amplify
commands to the resource.
@josefaidt Thanks! Is there a recommended approach to achieve the same affect? It seems like the parameters.json files may be intended for a similar purpose, but they don't seem environment aware like team-provider-info.json
.
In my case I'm trying to attach a Lambda function to a DynamoDB stream, so I need to grab the stream ARN for both dev and prod. This is kind of a band-aid though due my ignorance of how to properly sequence the stream association and DynamoDB table creation to just grab it using CloudFormation in the first place.
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
Authentication, Analytics, REST API, Push Notifications
Amplify Categories
auth, function, api, analytics, notifications
Environment information
Describe the bug
There it is my amplify stack:
I try to retrieve the pinpoint app id (associated to
Notifications foo
) and to use it in the definition of my lambda functionfooEndpoint
.When I try do an
amplify push
whenfooEndpoint
define a dependency withNotification foo
such it is supposed to looking for the pinpoint notification app id, the command raise the following error:Expected behavior
I expected to be able to retrieve and use the pinpoint notification app id as a parameters of my lambda function
Reproduction steps
Step 1: create an amplify project with notifications and a lambda functions.
(Even if you allow the lambda function to create/delete and so on with notifications services nothing happen)
Step 2:
Based on the documentation https://docs.amplify.aws/cli/usage/customcf#n3-optional-reference-existing-parameters I configure the following files as below:
amplify/backend/backend-config.json :
amplify/backend/function/fooEndpoint/parameters.json :
and
amplify/backend/function/fooEndpoint/fooEndpoint-cloudformation-template.json
withnotificationsFooId
in Parameters section (+ where I need it...)Step 3: amplify push
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response