Deep into the seventh year of his tenure, Barack Obama is thinking about his post-presidential legacy. We know this because he’s telling us so.

In an interview this week with The Atlantic about the potential deal with Iran regarding its nuclear program, the president sought to use the fact of his relative youth and his consciousness about how history might judge him to his advantage: “Look, 20 years from now, I’m still going to be around, God willing. If Iran has a nuclear weapon, it’s my name on this. I think it’s fair to say that in addition to our profound national-security interests, I have a personal interest in locking this down.”

In one sense, this is what we want presidents to worry about. We want them to be restrained by the cautionary examples provided by history and by the fact that history will judge them.

But what if the desire to tip the scales of history’s judgment in his favor leads a president to take dangerous risks?

In fact, we know that is what Obama has done with the Iran deal because his aides have told us so.

His deputy national security adviser, Ben Rhodes, put it this way last year to a roomful of liberal activists when talking about the initial November 2013 agreement to begin talking about Iran’s nuclear program: “Bottom line is, this is the best opportunity we’ve had to resolve the Iranian issue diplomatically … This is probably the biggest thing President Obama will do in his second term on foreign policy. This is health care for us, just to put it in context.”

But this “opportunity” didn’t just emerge organically — which is actually where “opportunities” are supposed to come from. It did not result from changing conditions that opened a new possibility of finding common ground.

Iran’s behavior didn’t change, and its pursuit of nuclear weapons didn’t change. Obama manufactured what Rhodes called an opportunity by pursuing a deal with Iran and dangling all kinds of carrots in front of the mullahs.

And why? Because he wants a foreign-policy legacy to match the size and scope of his key legacy in domestic policy.

And who can blame him? After the failure of the Arab Spring, the collapse of Libya, the failure to act on his self-imposed “red line” in Syria, Russia’s seizure of Crimea from Ukraine and the terrifying rise and forward march of ISIS, the only unmitigated positive on his foreign-policy spreadsheet remains the killing of Osama bin Laden.

Look, the guy will need something impressive to fill the exhibition space at his brand-new presidential library in Chicago.

Obama’s asking us to trust him because, he says, you can’t think he would want to look like the man who allowed Iran to go nuclear at some point in the future.

So what explains the president’s own unprompted comments in an NPR interview in April that, under the terms already announced, Iran would have the right to go nuclear by 2028 — when he will, God willing, be a mere 67 years of age?

“A more relevant fear,” he said, “would be that in year 13, 14, 15, they have advanced centrifuges that enrich uranium fairly rapidly, and at that point, the breakout times would have shrunk almost down to zero.”

Obama offered an answer. “The option of a future president to take action if in fact they try to obtain a nuclear weapon is undiminished,” he said.

So it will be up to his successors to bail him out in the eyes of history and make it appear as though his legacy wasn’t the nuclear destabilization of the Middle East!

Speaking of legacies, how’s that key domestic-policy legacy going? Not so hot.

ObamaCare remains unpopular; far more Americans oppose than favor it.

People still remember the disaster of the October 2013 rollout, which still casts a shadow over the program today.

Those hard feelings were deepened last year by the discovery of a series of talks by key ObamaCare architect Jonathan Gruber in which he bragged that it had been falsely marketed to the American people to take advantage of their stupidity.

Its defenders say the program is beginning to work, in the sense that it’s covering more people — but it’s not covering as many as the administration said it would by this time.

They tout the fact that the cost of the program is lower than it was supposed to be by now.

But that’s an inconsistent claim; it’s only less expensive because it isn’t meeting its target numbers, not because cost savings have suddenly materialized from the ether.

Meanwhile, at some point over the next month, the entire policy may be thrown into terminal chaos when the Supreme Court issues its judgment in a case called King v. Burwell — which challenges the legality of a central component of ObamaCare.

As the Supreme Court debates and writes its opinions, the overall economy continues to sputter. Over the past five years, it grows and halts, grows and halts, in a somewhat mystifying pattern that has kept the American people on guard and on edge.

In the latest RealClearPolitics polling average, 62 percent say the country is on the wrong track — more than seven years after Obama moved into the White House.

Obama still has 18 months to go, and presidents have staged remarkable turnarounds in public opinion in such a time frame. Bill Clinton did it before his re-election in 1996, which seemed like a ludicrous prospect in early 1995.

Ronald Reagan was at low ebb in mid-1987 and left office on a triumphant high in early 1989.

But we’ve also seen the opposite. Indeed, we’ve seen the opposite more recently. George W. Bush was in bad shape in mid-2007, unquestionably — worse than Obama, because he’d lost the confidence of some Republicans, while Obama seems not to have lost any of his base.

But in 2008, the bottom fell out when a financial crisis that began in the spring turned into a total meltdown by the fall. Bush left office with one poll showing his approval rating at 22 percent.

Right now, would you bet on things getting substantially better for Barack Obama, or substantially worse? Does it look like we’re going to triumph over ISIS?

Does it feel like the economy is going to improve or that ObamaCare will suddenly gain public support? Does it seem like the deal with Iran is a good one?

If you answer these questions in the affirmative, then you are likely to be the sort of person who’s kept your 2008 Obama “Hope” poster on your wall and your 2012 Obama bumper sticker on your car.

Alas for America and the world, a poster and a bumper sticker do not a legacy make.