-: Now that we've seen resources,
the second most important one
is going to be parameters.
And parameters are a way to provide inputs
to your AWS CloudFormation template.
They're super important to know about
if you want to reuse your templates across
the company or other accounts or regions.
And some inputs cannot be determined ahead of time.
For example, the keep area you're going
to link to instances.
Parameters are very powerful, they can be controlled,
and they can prevent errors down the line
happening in your templates, thanks to types.
So, we've used parameters before
in the first hands on, in which we basically
had to specify the security group description.
So, it was a string and we were asked
for the security group description,
and that was used in the security group itself.
So, you should use the parameter when basically
you ask yourself the question,
"Is this CloudFormation resource configuration
"likely to change in the future?"
If so, you can make it a parameter.
And by doing it as a parameter,
you don't have to re-upload a template to change content.
It's a bit more stable and a bit modualized.
If you do programming, and I hope you do,
you know the advantages of parameters.
Now, parameters can have different settings,
and they can be controlled in many different ways.
I don't think the exam requires you to know
all of these but, for me, for your interest,
I'm just going to name them.
You can have a typing string, number,
CommaDelimitedList, list of a type,
and an AWS Parameter.
As far as description, you can have constraints,
you can have a ConstraintDescription,
a minimum and a max length for string,
a minimum and a max value for numbers,
you can have defaults, AllowedValues
when you want to restrict the number of values
a user can pick, AllowedPattern when you want
to verify the inputs of a user using irregular expression,
and NoEcho if you want to pass in the secrets basically.
So, this is a lot of different optimizations
and parameters you can do.
For now, the only thing we've done is
use a simple string parameter in our thing,
and that's all you should know I think for the exam.
So, how do you reference a parameter?
Well, like this you have to use the function called Ref.
And so, this is the first time we encounter Ref
and functions, but basically interesting functions
in your templates allow you to supercharge it
and to link things up.
And so the Ref function is one of the most used,
and so you use it to reference parameters,
and this way you can use your parameters
anywhere in your templates, so in your resources,
for any type of inputs, and parameters, and configs.
So, the shorthand for a reference function in the YAML
is a little exclamation point Ref.
And this is why, it's just a way for us to have
a much nicer syntax, easier to recognize.
You can use the FN column call in Ref as well,
it's whatever you want, but most likely,
it's going to be this exclamation point Ref for shorthand.
And the function can also be used to reference
other elements within a template.
So, in the template we've been using,
in the parameter section, we had to find
a parameter name security group description.
Turns out that if we look all the way down,
the security group description was used
in this security group description key,
and so we used the Ref function to reference it.
So, this Ref function basically says,
"Whatever the user will put as a parameter value,
"for this parameter key, you want to use this,
"reference it into the group description."
So, it's very simple to think about.
It's just a reference.
But this reference function can also be used somewhere else.
It was used right here, for example,
for security groups, so you can see this reference function
also referenced the SSH security group
that was created under Resources.
So the Ref function can be used both to reference
parameters like the one before,
or it can also be used to reference resources.
So, here we've referenced the two security groups
and within the EIP, we reference MyInstance.
So, as you can see, the name of the reference
is the exact same name as the logical value under Resources.
Finally, you have a concept of Pseudo Parameters,
and these are AWS offer parameters that we can use,
and anytime they're enable by default,
and we get just a bunch of values
you may want to retrieve.
So, we can get an account ID, and you can just
give us the value of the account ID,
notification ARNs, no value if we don't want
to return the value.
We can also ask for the region in which
our address CloudFormation template is being run at,
so for example, US-east-2.
We can also get a pseudo parameter for the Stack ID
or the Stack name.
Basically, you don't need to know about these too much,
maybe the first one.
Account idea's very important to get the value
of the account ID if you were to try to construct
some complicated ARN value in your CloudFormation template.
But overall, you should just know that there is
this concept of pseudo parameters,
and again, you can use them at any time,
just use a Ref, and you're all set.
I hope that was helpful,
I hope you know how they work now
in your CloudFormation templates,
and I will see you in the next lecture.