Carolyn Brown, James Russell, and De-loise Fikes (collectively, “Insured”),1 proceeding pro se, appeal the district court’s dismissal of them complaint for breach of an insurance contract. They argue that the district court should have considered the merits of them claims against One Beacon Insurance Company (“One Beacon”) instead of dismissing them complaint as barred by the doctrine of res judicata.
I.
We review de novo the dismissal of a complaint pursuant to Federal Rule of Civil Procedure 12(b)(6). Davila v. Delta Air Lines, Inc., 326 F.3d 1183, 1185 (11th Cir.2003). We may affirm a dismissal “on any grounds supported in the record.” See Koziara v. City of Casselberry, 392 F.3d 1302, 1306 n. 2 (11th Cir.2004).
Dismissal is appropriate if, when accepting the plaintiffs factual allegations as true, “the plaintiff can prove no set of facts that would support the claims in the complaint.” Davila, 326 F.3d at 1185. “Generally, the existence of an affirmative defense will not support a motion to dismiss.” Quitter v. Barclays American/Credit, Inc., 727 F.2d 1067, 1069 (11th Cir.1984), en banc reh’g, 764 F.2d 1400, 1400 (11th Cir.1985) (per curiam) (reinstating panel opinion). “Nevertheless, a complaint may be *917dismissed under Rule 12(b)(6) when its own allegations indicate the existence of an affirmative defense, so long as the defense clearly appears on the face of the complaint.” Id. When determining a motion to dismiss, a court may consider the complaint, its attachments, and documents attached to the defendant’s motion to dismiss if the attached documents are central to the plaintiffs claims and referred to by the plaintiff without converting the motion to a motion for summary judgment. Brooks v. Blue Cross & Blue Shield of Fla., Inc., 116 F.3d 1364, 1368-69 (11th Cir.1997) (per curiam). We also review res judicata determinations de novo. Jang v. United Techs. Corp., 206 F.3d 1147, 1149 (11th Cir.2000). Although pro se pleadings are liberally construed, “this leniency does not give a court license to serve as de facto counsel for a party or to rewrite an otherwise deficient pleading in order to sustain an action....” GJR Invs., Inc. v. County of Escambia, Fla., 132 F.3d 1359, 1369 (11th Cir.1998) (citations omitted).
In a diversity case, federal courts will “give preclusive effect to the judgment of a state court provided that two conditions are met: first, that the courts of the state from which the judgment emerged would do so themselves; and second, that the litigants had a full and fair opportunity to litigate their claims and the prior state proceedings otherwise satisfied the applicable requirements of due process.” Shields v. Bellsouth Adver. & Publ’g Co., Inc., 228 F.3d 1284, 1288 (11th Cir.2000) (internal quotation marks and citations omitted).
“Res judicata and collateral estoppel ... are two separate rules or sets of rules for determining the conclusiveness of judgments.” Wheeler v. First Alabama Bank of Birmingham, 364 So.2d 1190, 1199 (Ala.1978). “Under Alabama law, the essential elements of res judicata are (1) a prior judgment on the merits, (2) rendered by a court of competent jurisdiction, (3) with substantial identity of the parties, and (4) with the same cause of action presented in both suits.” Wesch v. Folsom, 6 F.3d 1465, 1471 (11th Cir.1993); see also Wheeler, 364 So.2d at 1199 (state supreme court case stating elements of res judicata). “If these elements are present, then the former judgment is an absolute bar to any subsequent suit on the same cause of action, including any issue which was or could have been litigated in the prior action.” Wheeler, 364 So.2d at 1199.
“Collateral estoppel operates where the subsequent suit between the same parties is not on the same cause of action.” Id. Collateral estoppel requires that: (1) the issue be identical to one the issue involved in previous suit; (2) the issue be actually litigated in prior action; and (3) the resolution of the issue be necessary to the prior judgment. Id. “If these elements are present, the prior judgment is conclusive as to those issues actually determined in the prior suit.” Id.
“[RJes judicata is an affirmative defense....” Norfolk S. Corp. v. Chevron, U.S.A., Inc., 371 F.3d 1285, 1289 (11th Cir.2004). The doctrine of res judicata in conjunction with 28 U.S.C. § 1738, the Full Faith and Credit Statute, bars relitigation of matters that were previously litigated in a prior state suit. Saboff v. St. John’s River Water Mgmt. Dist., 200 F.3d 1356, 1359 (11th Cir.2000). Section 1738. requires “a federal court must give to a state-court judgment the same preclusive effect as would be given that judgment under the law of the State in which the judgment was rendered.” Migra v. Warren City Sch. Dist. Bd. of Educ., 465 U.S. 75, 81, 104 S.Ct. 892, 896, 79 L.Ed.2d 56 (1984). Thus, the “relevant inquiry is whether [Alabama’s] law of res judicata *918would ordinarily bar [the plaintiffs’] subsequent federal claim[ ]”. Saboff 200 F.3d at 1360.
When the parties “consent” to the dismissal of a suit “based on a settlement agreement ... the principles of res judica-ta apply (in a somewhat modified form) to the matters specified in the settlement agreement, rather than the original complaint.” Norfolk, 371 F.3d at 1288. “In determining the res judicata effect of an order of dismissal based upon a settlement agreement, [the court] should also attempt to effectuate the parties’ intent. The best evidence of that intent is, of course, the settlement agreement itself.” Id. at 1289. Ultimately, Alabama law does give judgments approving settlements conclusive and binding effect. See Ala.Code § 25-5-56; see also Lawrence v. U.S. Fidelity & Guar. Co., 226 Ala. 161, 145 So. 577 (1933) (holding that judgment approving settlement may be given res judicata effect).
Alabama uses the substantial evidence test to determine whether two causes of action are the same for res judicata purposes. Equity Res. Mgmt., Inc. v. Vinson, 723 So.2d 634, 637 (Ala.1998). Under this test, res judicata applies when the same evidence substantially sujoports both actions. Id.
As the Supreme Court of Alabama has explained:
it is well-settled that the principal test for comparing causes of action [for the application of res judicata] is whether the primary rigid and duty or wrong are the same in each action. Res judi-cata applies not only to the exact legal theories advanced in the prior case, but to all legal theories and claims arising out of the same nucleus of operative facts.
Old Republic Ins. Co. v. Lanier, 790 So.2d 922, 928 (Ala.2000) (emphasis added) (internal quotation marks and citations omitted).
Here, the Insured filed a claim in state court against One Beacon for breach of contract. The parties mediated their claims, and in 2005, One Beacon settled with the Insured. Subsequently, the Insured alleged to the state trial court that One Beacon had failed to pay the full amount required by the mediation settlement agreement. However, the state trial court enforced the agreement against the Insured, terminating the litigation. The Insured were unsuccessful in their appeal to the Alabama Court of Appeals.
The Insured then brought suit against One Beacon in federal court. In their federal complaint, the Insured request compensation for their destroyed home and furnishings and for living expenses incurred, as well as for One Beacon’s malicious, grossly negligent, and willful breach of their insurance contract. Because the Insured have fully litigated these claims in state court, their federal complaint is barred by res judicata.
The Insured’s complaint demonstrates that their federal action involves the same parties and causes of action that were fully and previously resolved by a state court of competent jurisdiction. The district court properly dismissed the action under Rule 12(b)(6) as barred by the doctrine of res judicata in accord with Alabama law. See Saboff 200 F.3d at 1359. Moreover, to the extent the cause of action in state court action differed from any cause of action which could be liberally construed as underlying the present case (e.g., breach of the state court settlement agreement), collateral estoppel applied to preclude reliti-gation of whether the settlement agreement was binding and should be enforced, and warranted dismissal on that basis. See Wheeler, 364 So.2d at 1199.
*919 CONCLUSION
Upon review of the record and the parties’ briefs, we discern no reversible error. Accordingly, we affirm.
AFFIRMED.