Role is invalid or cannot be assumed on sls deploy - serverless

I've got error on sls deploy:
Role arn:aws:iam::542779088875:role/serverless-role is invalid or cannot be assumed
I don't understand where this role comes from. At first, I didn't have role named like this. Then, I've created new role named serverless-role and selected it at dashboard.serverless.com, but I still get this error.
Stack removal doesn't help either (I get the same error).
What am I doing wrong?

Serverless tries to create Stack with this CloudFormation role, so creating CloudFormation role named serverless-role worked out.

Related

Cause Document Error I got CognitoIdentityCredentials is not authorized to perform: dynamodb:UpdateItem on resource

I found the document wrong, because the wrong always cannot run success, certainly I also had wrong, I did not see clear, if you suffer now, please just checked as below:
dynamoDBTableName -> String
In the wrong document, the wrong as below:
In the "Amazon DynamoDB: Store and Retrieve App Data"
at "Create a DynamoDB Table and Index"
It say
3.Enter "Books" as the name of the table
But at sample code write below:
Class func dynamoDBTableName () -> String {
       Return "Book"
}
Is not return "Book", should return "Books", no wonder, haha, I always got the error "CognitoIdentityCredentials is not authorized to perform: dynamodb: UpdateItem on resource"
If you also always error, checks your table name return same, have nice day.
The error which you are getting indicates that you dont have correct IAM policies attached to your Cognito Role. If you are using an unauth role you need to grant permissions to update item on dynamodb table to that unauth role. Same goes for auth role.
Thanks,
Rohan

Trouble assigning user access levels

I'm following this tutorial, as I wanted to learn how to create user authorization with singular roles (each user has one role) from scratch rather than using a gem like rolify that does it all for me, but I'm hung up on assigning the users access levels.
When I type erin = User.find(9) in the console it finds my test#test.com user. I try to issue the erin.admin! command but it throws an error about the password? (ActiveRecord::RecordInvalid: Validation failed: Password can't be blank).
I've also tried erin.access_level = "admin" which returns "admin" while I'm still in the console but no longer exists when I exit the console, fire up the rails server and try to test out my test#test.com user in my app.
Is there any other way to assign access levels? Am I just doing it wrong?
The User record cannot be saved because a validation exists that requires a password. I don't know if there are special rules for the format of the password, but you can easily set a password so that you can save the user:
user = User.find(9)
user.password = 'Test1234'
user.password_confirmation = 'Test1234' # you might need this as well
user.access_level = 'admin'
user.save #=> true
If user.save returns false, check user.errors for any other validation errors that would cause the record not to save.
For the second part of my question, where my database didn't seem to deploy to Heroku, it's because I was working in the dev db, not the production db.
To do that, I ran "heroku run rails console" and then followed the above steps to give a user admin access levels. More here: https://devcenter.heroku.com/articles/getting-started-with-rails4#console

symfony - credentials problem

I am trying to fully understand how the credentials/permissions system works in symfony(1.4)
I have 2 groups and 2 users.
User 1 has the following permissions:
Add.Car, Delete.Car
User 2 has the following permissions:
Add.Bike, Delete.Bike
Now what I want to do, is only allow users with the Add.x permissions to be able to add to a category table.
The problem is, that If I have:
credentials: [Add.Car, Add.Bike] - it seems to look for users with BOTH of these, not either of them.
Is this how the credentials work and If so, is there a way to check if the user has either Add.Bike OR Add.Car before allowing them to create new records?
Thanks
Wrap the credentials in [ ]
credentials: [[Add.Car, Add.Bike]]
see http://www.symfony-project.org/jobeet/1_4/Doctrine/en/13 'Complex Credentials' section

sfGuardAuth across multiple apps

I've got 3 apps: Backend, Frontend and Members.
And I've got 2 credentials: Administrators and Members.
Administrators are imported by default but Members are created in the Backend.
When a Member is created, an event handler also inserts this Member as a sf_guard_user and of course, the proper relations in sf_guard_user_group and sf_guard_user_permission.
That's the boring part, now the fun:
Frontend is not secured, but Members is and using these credentials: [administrator, member].
According to all this, Members created in the Backend that also get inserted (correctly as far as I can tell) should be able to login to the Members secured app, since they get the member group/permission/credential.
This is not happenning, the only ones that can login to the Members app are the administrators, which is not wrong, but either is the fact that correctly created Member users can't login to it.
The error thrown by the guard is the classic: The username and/or password is invalid.
Now that I edit the error, the salt comes to mind: How would one emulate the inserting of the salt as the guard does it? Maybe that's what I'm not inserting correctly (or inserting at all) and thus the password invalid error (and in fact everythine else I've described is ok! omg)
And that's my problem.
Thanks in advance :)
[administrator, member] means both are required, I believe.
I think you want [[administrator, member]] for the credential requirement.
Also, yes, you will want to make sure you use a salt, and set the algo.
parent::_set('password', call_user_func_array($algorithm, array($salt.$password)));
Salt before password, as well.

How to access global variable in a view in Ruby on Rails?

I have a User model.
I have a Session controller, in which I have a global user variable that is assigned as follows:
$user = User.authenticate(params[:session][:email], params[:session][:password])
(I've made user global just to try to solve this problem, so if there's a better way please let me know!)
I need to use the email of the logged in user as a parameter to send to Flex part of my website. At the moment I'm creating the link as follows:
<%= link_to "secondpage", secondpage_path(:email => #session.$user.email)
But I'm getting the following error:
compile error
/Users/benhartney/rails_projects/talk/app/views/layouts/_header.html.erb:12:
syntax error, unexpected tGVAR
..._path(:email =>
#session.$user.email) ).to_s);
#output_buffe...
There's also a little arrow pointing at $user
If I remove the $ from $user, I get this error:
undefined method `user' for
nil:NilClass
If I remove the
(:email => #session.user.email)
part, everything works fine, so I think all of the code except for this is ok.
Can anyone tell me what I'm doing wrong?
Thanks for reading!
I think what you are looking for is a session variable.
Rails is primarily a framework for creating web applications, and http is stateless, i.e. each request knows nothing about what went on before. To get over this limitiation, web developers use cookies or session variables to simulate maintenance of state, i.e. data, across requests.
Check out http://guides.rubyonrails.org/action_controller_overview.html#session
You can't have a global variable local to something, as far as I understand (this time, you can't have a global variable that is local to session)
Try using :email => $user.email
if you're adamant that you need a global variable for something.
You can also try
Thread.current[:email]

Resources