Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
derBroBro committed Sep 21, 2017
0 parents commit b595bcf
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Zoi TechCon GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# AWS generic account setup
Terraform module which creates AWS access via SAML.
* Create SAML Provider
* Create Role for SAML access
* Attach given set of policies

## Usage
```hcl
module "saml" {
source = "zoitech/saml/aws"
role_name = "SAML-Admin"
provider_metadata_url = "https://something.com/metadata.xml"
}
```

## Authors
Module managed by [Zoi](https://github.com/zoitech).

## License
MIT License. See LICENSE for full details.
4 changes: 4 additions & 0 deletions iam_providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource "aws_iam_saml_provider" "saml" {
name = "${var.provider_name}"
saml_metadata_document = "${file(var.provider_metadata_file)}"
}
27 changes: 27 additions & 0 deletions iam_roles.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
resource "aws_iam_role" "DelegateUser" {
name = "${var.role_name}"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "${aws_iam_saml_provider.saml.id}"
},
"Action": "sts:AssumeRoleWithSAML",
"Condition": {
"StringEquals": {
"SAML:aud": "https://signin.aws.amazon.com/saml"
}
}
}
]
}
EOF
}
resource "aws_iam_role_policy_attachment" "DelegateUser_Attachment" {
role = "${aws_iam_role.DelegateUser.name}"
policy_arn = "${element(var.role_policies, count.index)}"
count = "${length(var.role_policies)}"
}
8 changes: 8 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
output "role"{
description = "ARN of the Role"
value = "${aws_iam_role.DelegateUser.id}"
}
output "saml_provider"{
description = "ARN of the SAML Provider"
value = "${aws_iam_saml_provider.saml.id}"
}
3 changes: 3 additions & 0 deletions providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
provider "aws" {
region = "${var.aws_region}"
}
26 changes: 26 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Settings
# Account ID
data "aws_caller_identity" "current" { }

variable "aws_region" {
description = "The reqion where the ressrouces should be create. Unimportant as IAM."
default = "eu-central-1"
}
variable "role_name" {
description = "The name of the Role"
default = "Delegate-Saml-Admin"
}
variable "role_policies" {
description = "The policies attached to the role"
default = ["arn:aws:iam::aws:policy/AdministratorAccess"]
type = "list"
}

variable "provider_name" {
description = "The name of the provider."
default = "default-saml-provider"
}
variable "provider_metadata_file" {
description = "The path to of the metadatafile"
default =""
}

0 comments on commit b595bcf

Please sign in to comment.