Parameters, mappings & outputs
Make a template reusable.
Hard-coded templates are single-use; Parameters make one template serve many deployments. A parameter declares a typed input with an optional default, allowed values, and constraints, and you supply it at deploy time. The program refers to it with !Ref, so the same template can deploy a t3.small in dev and a t3.large in prod purely by changing the parameter.
Parameters:Environment:Type: StringAllowedValues: [dev, staging, prod]Default: devInstanceType:Type: StringDefault: t3.smallAllowedValues: [t3.small, t3.large]Resources:AppServer:Type: AWS::EC2::InstanceProperties:InstanceType: !Ref InstanceTypeTags: [{ Key: Env, Value: !Ref Environment }]
Mappings and Outputs
Mappings are static lookup tables resolved with !FindInMap — the classic use is picking a region-specific AMI. Outputs publish values from the stack: an endpoint, a bucket name, a security group ID. An Output can be exported with a name, which lets another stack import it (cross-stack references, covered later) — making Outputs both a human-facing result and a machine-facing contract between stacks.
Mappings:RegionAmi:us-east-1: { ami: ami-0abc123 }eu-west-1: { ami: ami-0def456 }Resources:AppServer:Type: AWS::EC2::InstanceProperties:ImageId: !FindInMap [RegionAmi, !Ref "AWS::Region", ami]Outputs:ServerId:Value: !Ref AppServerExport: { Name: !Sub "${Environment}-app-server-id" }