Skip to content

JamesWoolfenden/terraform-aws-imagebuilder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terraform-aws-imagebuilder

Build Status Latest Release GitHub tag (latest SemVer) Terraform Version Infrastructure Tests pre-commit checkov Infrastructure Tests

Terraform module - creates Aurpora cluster and instances


It's 100% Open Source and licensed under the APACHE2.

Usage

This is just a basic illustration of the resources.

Include this repository as a module in your existing terraform code:

module "imagebuilder" {
  source          = "JamesWoolfenden/imagebuilder/aws"
  version         = "0.0.2"
  common_tags     = var.common_tags
  instances       = var.instances
  cluster         = var.cluster
}

IAM Permissions

{}

IAC comparison

The makefile in the example runs 4 of the main IAC SAST tools:

  • Checkov
  • TFSec
  • Terrascan
  • Kics

You can run these as part of the validate scripts contained here and all 4 will output to the output folder.

Requirements

No requirements.

Providers

Name Version
aws n/a

Modules

No modules.

Resources

Name Type
aws_iam_instance_profile.examplea resource
aws_iam_role.ssm resource
aws_iam_role_policy_attachment.builder resource
aws_imagebuilder_component.examplea resource
aws_imagebuilder_distribution_configuration.examplea resource
aws_imagebuilder_image.examplea resource
aws_imagebuilder_image_pipeline.examplea resource
aws_imagebuilder_image_recipe.examplea resource
aws_imagebuilder_infrastructure_configuration.examplea resource
aws_key_pair.pike resource
aws_s3_bucket.imagebuilder resource
aws_s3_bucket_acl.imagebuilder resource
aws_s3_bucket_public_access_block.imagebuilder resource
aws_s3_bucket_server_side_encryption_configuration.imagebuilder resource
aws_partition.current data source
aws_region.current data source

Inputs

Name Description Type Default Required
common_tags This is to help you add tags to your cloud objects map(any) n/a yes
component n/a string n/a yes
component_name n/a string "examplea" no
component_version n/a string "1.0.0" no
dist_name n/a string "examplea" no
instance_profile_name n/a string "examplea" no
kms_key n/a any n/a yes
platform n/a string "Linux" no
public_key public key material string n/a yes
security_group_ids (optional) describe your variable list(string) n/a yes
subnet_id (optional) describe your variable string n/a yes
user_ids n/a list(any) [] no

Outputs

Name Description
component n/a
configuration n/a
image n/a
recipe n/a

Policy

This is the policy required to build this project:

The Terraform resource required is:

resource "aws_iam_policy" "terraform_pike" {
  name_prefix = "terraform_pike"
  path        = "/"
  description = "Pike Autogenerated policy from IAC"

  policy = jsonencode({
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "ec2:CreateKeyPair",
                "ec2:DeleteKeyPair",
                "ec2:DescribeAccountAttributes",
                "ec2:DescribeImages",
                "ec2:DescribeKeyPairs",
                "ec2:ImportKeyPair"
            ],
            "Resource": "*"
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": [
                "iam:AddRoleToInstanceProfile",
                "iam:AttachRolePolicy",
                "iam:CreateInstanceProfile",
                "iam:CreateRole",
                "iam:CreateServiceLinkedRole",
                "iam:DeleteInstanceProfile",
                "iam:DeleteRole",
                "iam:DetachRolePolicy",
                "iam:GetInstanceProfile",
                "iam:GetRole",
                "iam:ListAttachedRolePolicies",
                "iam:ListInstanceProfilesForRole",
                "iam:ListRolePolicies",
                "iam:PassRole",
                "iam:RemoveRoleFromInstanceProfile"
            ],
            "Resource": "*"
        },
        {
            "Sid": "VisualEditor2",
            "Effect": "Allow",
            "Action": [
                "imagebuilder:CreateComponent",
                "imagebuilder:CreateDistributionConfiguration",
                "imagebuilder:CreateImage",
                "imagebuilder:CreateImagePipeline",
                "imagebuilder:CreateImageRecipe",
                "imagebuilder:CreateInfrastructureConfiguration",
                "imagebuilder:DeleteComponent",
                "imagebuilder:DeleteDistributionConfiguration",
                "imagebuilder:DeleteImage",
                "imagebuilder:DeleteImagePipeline",
                "imagebuilder:DeleteImageRecipe",
                "imagebuilder:DeleteInfrastructureConfiguration",
                "imagebuilder:GetComponent",
                "imagebuilder:GetDistributionConfiguration",
                "imagebuilder:GetImage",
                "imagebuilder:GetImagePipeline",
                "imagebuilder:GetImageRecipe",
                "imagebuilder:GetInfrastructureConfiguration",
                "imagebuilder:Getimage",
                "imagebuilder:TagResource",
                "imagebuilder:UntagResource",
                "imagebuilder:UpdateDistributionConfiguration",
                "imagebuilder:UpdateImagePipeline",
                "imagebuilder:UpdateInfrastructureConfiguration"
            ],
            "Resource": "*"
        },
        {
            "Sid": "VisualEditor3",
            "Effect": "Allow",
            "Action": [
                "kms:Decrypt",
                "kms:Encrypt",
                "kms:GenerateDataKey",
                "kms:GenerateDataKeyWithoutPlaintext"
            ],
            "Resource": "*"
        },
        {
            "Sid": "VisualEditor4",
            "Effect": "Allow",
            "Action": [
                "s3:CreateBucket",
                "s3:DeleteBucket",
                "s3:GetAccelerateConfiguration",
                "s3:GetBucketAcl",
                "s3:GetBucketCORS",
                "s3:GetBucketLogging",
                "s3:GetBucketObjectLockConfiguration",
                "s3:GetBucketPolicy",
                "s3:GetBucketPublicAccessBlock",
                "s3:GetBucketRequestPayment",
                "s3:GetBucketTagging",
                "s3:GetBucketVersioning",
                "s3:GetBucketWebsite",
                "s3:GetEncryptionConfiguration",
                "s3:GetLifecycleConfiguration",
                "s3:GetObject",
                "s3:GetObjectAcl",
                "s3:GetReplicationConfiguration",
                "s3:ListAllMyBuckets",
                "s3:ListBucket",
                "s3:PutBucketAcl",
                "s3:PutBucketPublicAccessBlock",
                "s3:PutEncryptionConfiguration"
            ],
            "Resource": "*"
        }
    ]
})
}

Related Projects

Check out these related projects.

Help

Got a question?

File a GitHub issue.

Contributing

Bug Reports & Feature Requests

Please use the issue tracker to report any bugs or file feature requests.

Copyrights

Copyright 2019-2022 James Woolfenden

License

License

See LICENSE for full details.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Contributors

James Woolfenden
James Woolfenden