この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。
こんにちは、AWS事業本部の島川です。
Terraformがre:Invent期間中に発表されたいくつかのAWSサービスに対応していましたので、紹介します!
アップデートまとめ
AWS BranchConnect(VPC Ingress Routing)
サービス概要
[VPC Ingress Routing]IGWとVGWにルートテーブルをアタッチ!全ての通信をEC2経由へ。サードパーティIDS製品などの通信をシンプルに #reinvent
サンプルコード
resource "aws_route_table_association" "example" {
gateway_id = aws_internet_gateway.example.id
route_table_id = aws_route_table.example.id
}
Amazon EKS Managed Node Groups
こちらだけre:Inventの前の週くらいにアップデートが発表されたサービスです。
サービス概要
サンプルコード
resource "aws_iam_role" "example" {
name = "eks-node-group-example"
assume_role_policy = jsonencode({
Statement = [{
Action = "sts:AssumeRole"
Effect = "Allow"
Principal = {
Service = "ec2.amazonaws.com"
}
}]
Version = "2012-10-17"
})
}
resource "aws_iam_role_policy_attachment" "example-AmazonEKSWorkerNodePolicy" {
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy"
role = aws_iam_role.example.name
}
resource "aws_iam_role_policy_attachment" "example-AmazonEKS_CNI_Policy" {
policy_arn = "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy"
role = aws_iam_role.example.name
}
resource "aws_iam_role_policy_attachment" "example-AmazonEC2ContainerRegistryReadOnly" {
policy_arn = "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"
role = aws_iam_role.example.name
}
# Example Subnets for EKS Node Group
data "aws_availability_zones" "available" {
state = "available"
}
resource "aws_subnet" "example" {
count = 3
availability_zone = data.aws_availability_zones.available.names[count.index]
cidr_block = cidrsubnet(aws_vpc.example.cidr_block, 8, count.index)
vpc_id = aws_vpc.example.id
tags = {
"kubernetes.io/cluster/${aws_eks_cluster.example.name}" = "shared"
}
}
# Example EKS Node Group
resource "aws_eks_node_group" "example" {
cluster_name = aws_eks_cluster.example.name
node_group_name = "example"
node_role_arn = aws_iam_role.example.arn
subnet_ids = aws_subnet.example[*].id
scaling_config {
desired_size = 1
max_size = 1
min_size = 1
}
}
Amazon EKS for AWS Fargate
サービス概要
サンプルコード
resource "aws_eks_fargate_profile" {
cluster_name = aws_eks_cluster.example.name
name = "example_fargate_profile"
pod_execution_role_arn = aws_iam_role.example.arn
subnet_ids = aws_subnet.example[*].id
tags = {
TagKey1 = “TagValue1”
}
selectors {
labels = {
LabelKey1 = “LabelValue1”
}
namespace = "example-namespace"
}
}
AWS Lambda Provisioned Concurrency
サービス概要
[速報]コールドスタート対策のLambda定期実行とサヨナラ!! LambdaにProvisioned Concurrencyの設定が追加されました #reinvent
サンプルコード
resource "aws_lambda_alias" "example" {
function_name = aws_lambda_function.example.function_name
function_version = aws_lambda_function.example.version
name = "example"
}
resource "aws_lambda_provisioned_concurrency_config" "example" {
function_name = aws_lambda_alias.example.function_name
provisioned_concurrent_executions = 100
qualifier = aws_lambda_alias.example.name
}
まとめ
対応力の速さにビックリです。今回の目玉アップデートの一つであるAmazon EKS for AWS Fargateに対応しているのには嬉しい方も多いのではないでしょうか。
参考URL
HashiCorp at re:Invent ‘19: Terraform Supports Newly Announced AWS Services