AWS IAM SAML Provider
This page shows how to write Terraform and CloudFormation for IAM SAML Provider and write them securely.
aws_iam_saml_provider (Terraform)
The SAML Provider in IAM can be configured in Terraform with the resource name aws_iam_saml_provider
. The following sections describe 5 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_iam_saml_provider" "idp_saml" {
name = "idp_saml"
saml_metadata_document = file("saml-metadata.xml")
}
resource "aws_iam_saml_provider" "second_idp_saml" {
resource "aws_iam_saml_provider" "idp_saml" {
name = "idp_saml"
saml_metadata_document = file("saml-metadata.xml")
}
resource "aws_iam_saml_provider" "second_idp_saml" {
resource "aws_iam_saml_provider" "idp_saml" {
name = "idp_saml"
saml_metadata_document = file("saml-metadata.xml")
}
resource "aws_iam_saml_provider" "second_idp_saml" {
resource "aws_iam_saml_provider" "idp_saml" {
name = "idp_saml"
saml_metadata_document = file("saml-metadata.xml")
}
resource "aws_iam_saml_provider" "second_idp_saml" {
resource "aws_iam_saml_provider" "idp_saml" {
name = "idp_saml"
saml_metadata_document = file("saml-metadata.xml")
}
resource "aws_iam_saml_provider" "second_idp_saml" {
Parameters
-
arn
optional computed - string -
id
optional computed - string -
name
required - string -
saml_metadata_document
required - string -
tags
optional - map from string to string -
valid_until
optional computed - string
Explanation in Terraform Registry
Provides an IAM SAML provider.
Tips: Best Practices for The Other AWS IAM Resources
In addition to the aws_iam_account_password_policy, AWS IAM has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.
aws_iam_account_password_policy
Ensure AWS IAM account password policies requires long passwords
It's better to enforce the use of long and complex passwords to reduce the risk of bruteforce attacks.
AWS::IAM::SAMLProvider (CloudFormation)
The SAMLProvider in IAM can be configured in CloudFormation with the resource name AWS::IAM::SAMLProvider
. The following sections describe 4 examples of how to use the resource and its parameters.
Example Usage from GitHub
Type: 'AWS::IAM::SAMLProvider'
Properties:
Name: !Ref SamlProviderName
SamlMetadataDocument: !Ref MetadataDocument
SamlProviderRole:
Type: AWS::IAM::Role
"type": "AWS::IAM::SAMLProvider"
}
],
"eventType": "AwsApiCall",
"recipientAccountId": "123456789012"
"AWS::IAM::SAMLProvider": {
"Type": "AWS::IAM::SAMLProvider",
"Properties": {}
},
"AWS::Inspector::ResourceGroup": {
"Type": "AWS::Inspector::ResourceGroup",
Parameters
-
Name
optional - String -
SamlMetadataDocument
required - String -
Tags
optional - List of Tag
Explanation in CloudFormation Registry
Creates an IAM resource that describes an identity provider (IdP) that supports SAML 2.
The SAML provider resource that you create with this operation can be used as a principal in an IAM role's trust policy. Such a policy can enable federated users who sign in using the SAML IdP to assume the role. You can create an IAM role that supports Web-based single sign-on (SSO) to the AWS Management Console or one that supports API access to AWS.
When you create the SAML provider resource, you upload a SAML metadata document that you get from your IdP. That document includes the issuer's name, expiration information, and keys that can be used to validate the SAML authentication response (assertions) that the IdP sends. You must generate the metadata document using the identity management software that is used as your organization's IdP.
Note This operation requires Signature Version 4. For more information, see [Enabling SAML 2.
0 federated users to access the AWS Management Console ](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_enable-console-saml.html) and [About SAML 2.
0-based federation](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_saml.html) in the IAM User Guide.
Frequently asked questions
What is AWS IAM SAML Provider?
AWS IAM SAML Provider is a resource for IAM of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.
Where can I find the example code for the AWS IAM SAML Provider?
For Terraform, the anmoltoppo/Terraform, madhuawsdemo/modules and terraform-aws-modules/terraform-aws-iam source code examples are useful. See the Terraform Example section for further details.
For CloudFormation, the Sage-Bionetworks/aws-infra, vikyol/aws-tags and mhlabs/aws-icons-directory source code examples are useful. See the CloudFormation Example section for further details.