-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Lambda custom policies not working #8392
Comments
@osddeitf Can you share your custom policies file? I tried it with 6.2.1 and don't see that error |
I already shared it above, but this is how I reproduced it just now:
[
{
"Effect": "Allow",
"Action": ["cloudfront:*"],
"Resource": ["arn:aws:cloudfront:::*"]
}
]
I tried with different
I run amplify inside this Docker image: FROM node:14-bullseye-slim
RUN npm i -g @aws-amplify/cli
USER node
CMD [ "bash" ] |
Anyway, the way it removed the existing custom policy in the template files is definitely a breaking change. |
This may be due to wrong usage of export const CustomIAMPoliciesSchema = {
type : 'array',
minItems: 1,
items: {
type: 'object',
properties: {
Action: { type: 'array', items: { type: 'string' }, minItems: 1, nullable: false },
Resource: { type: 'array', items: { type: 'string' }, minItems: 1, nullable: false }
},
optionalProperties: {
Effect: { type: 'string', enum:['Allow', 'Deny'], default: 'Allow' },
},
required: ['Resource', 'Action'],
additionalProperties: true
},
additionalProperties: false
} According to ajv docs: |
The above schema |
I think I found the problem:
We should pin |
I am having this same issue using 6.3.1 cli. |
@grovejc I created a PR for fixing this already, hopefully it will soon be landed in a release. |
Is there a workaround for this? It's blocking my CI at the moment, as Amplify's built-in CI auto-patches to the latest version. |
@bensewell As I wrote in the PR, for linux, specifically inside official
|
Hello, I have the same issue on CI but not when I execute it in localhost. On localhost I have amplify-cli 6.3.1. |
@dudzin, and for anyone having issue with CI.
They are having a lot of works going on in transform v2 or some sorts. So I think newer version of amplify-cli than 6.3.1 won't come out soon. |
I think I've found a way of applying the patch above in CI for Amplify. In your amplify.yml (which is either in the root of your repo, or under Build Settings in the console), add a backend section - I've put my amplify.yml here for reference: https://gist.github.com/bensewell/60b9aafa23c156e98735b66b702aaf53 |
v6.4.0 released, it's time to test it. |
Hey @osddeitf 👋 just wanted to follow-up here and see if you're still experiencing this issue after the merge? |
Sorry, i forgot to close this issue. |
No worries @osddeitf ! Thank you for the contribution! 🚀 |
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Before opening, please confirm:
How did you install the Amplify CLI?
No response
If applicable, what version of Node.js are you using?
No response
Amplify CLI Version
6.2.1
What operating system are you using?
Debian Bullseye
Amplify Categories
function
Amplify Commands
push
Describe the bug
I have added custom policy for my lambda function in
<function_name>-cloudformation-template.json
:When I updated Amplify CLI from v6.1.1 to v6.2.1, when I run
amplify push
, it remove my custom policy.Then I noticed a change in v6.2.0:
Then I create
custom-policies.json
according to the updated documentation, with the following content:Then run
amplify push
, the error showed up as below:Expected behavior
It should work. I tried the example in the docs, also won't work:
Reproduction steps
As described above
GraphQL schema(s)
# Put schemas below this line
Log output
Additional information
I have tried to clean all of my workspaces, run
amplify init
thenamplify pull
again, the error still persisted.The text was updated successfully, but these errors were encountered: