Cook made 115 and Amla hit 109 in a South Africa total of 329 for five at the close of play.
The pair put on 202 for the second wicket before Amla's dismissal sparked a collapse in which four wickets, including that of Cook, fell for 36 runs.
Temba Bavuma and Quinton de Kock restored South Africa's advantage with an unbeaten sixth wicket stand of 56.
Cook, called up at the age of 33 when the South African selectors finally opted for a specialist opening batsman to partner Dean Elgar, was calm and organised from the start of his 218-ball innings during which he hit 14 boundaries.
Also Read
He hit one more four before he was bowled off an inside edge by Ben Stokes.
Cook was on 97 when Amla was dismissed and was still two short of his century when AB de Villiers was caught at second slip off Stuart Broad for his second duck in three innings since being appointed captain.
Cook went to his century off 187 balls when he tucked Stokes through midwicket for two and added 15 more runs before edging a ball from Chris Woakes into his stumps.
In contrast to his father, Jimmy, who was dismissed first ball on his Test debut against India in 1992/93, Stephen Cook scored four off the first ball he faced, a leg side half volley from James Anderson.
Jimmy Cook, who was in the crowd on Friday, had to wait until the age of 39 to make his official Test debut after being a prolific scorer for South Africa in 19 unofficial "rebel" Tests during South Africa's political isolation, including a hundred on debut against an English team in 1981/82.