While solving these type of questions simply use one trick.
Take variable on LHS, from that variable draw output operations such as :
S -> bS
means S on seeing b goes to S again.
S --> aA
means S on seeing a goes to A.
Overall DFA is :
Let input string is aaa.
By using Grammar : S --> aA --> aaB --> aaa.
Using DFA : (S, a) = A
(A,a) = B
(B,a) = S accepted.