Skip to content

Commit ceb4be6

Browse files
authored
chore: Gitlab e2e tests (#26)
* gitlab e2e tests * Update tags * install opentofu * AWS cross account config * Install AWC CLI * nit clean up * Use unique identifier in test resources * Remove inference accelerator * 10 second sleep * Add retry in terraform options * Retryable Terraform Errors * Increase retry * Replace opentofu with tf * Enable locking * Update the provider retries * Null blocker * Update test prefix in tests * Pin the AWS CLI version * Misc clean up * Use base image with awscli
1 parent 9f772ad commit ceb4be6

20 files changed

+78
-31
lines changed

.gitlab-ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
stages:
2+
- test
3+
4+
tests:
5+
stage: test
6+
image: registry.ddbuild.io/ci-containers-project:v50051243-ace27e7-v1.22
7+
tags:
8+
- "arch:amd64"
9+
before_script:
10+
# Setup Terraform
11+
- curl -fsSL https://releases.hashicorp.com/terraform/1.6.6/terraform_1.6.6_linux_amd64.zip -o terraform.zip
12+
- unzip terraform.zip > /dev/null
13+
- mv terraform /usr/local/bin/terraform
14+
- chmod +x /usr/local/bin/terraform
15+
- terraform version
16+
17+
# Setup AWS credentials
18+
- echo "Assuming ddbuild-terraform-aws-ecs-datadog role"
19+
- roleoutput=$(aws sts assume-role --role-arn arn:aws:iam::669783387624:role/ddbuild-terraform-aws-ecs-datadog --external-id ddbuild-terraform-aws-ecs-datadog-ci --role-session-name terraform-aws-ecs-datadog-ci)
20+
- export AWS_ACCESS_KEY_ID="$(echo "$roleoutput" | jq -r '.Credentials.AccessKeyId')"
21+
- export AWS_SECRET_ACCESS_KEY="$(echo "$roleoutput" | jq -r '.Credentials.SecretAccessKey')"
22+
- export AWS_SESSION_TOKEN="$(echo "$roleoutput" | jq -r '.Credentials.SessionToken')"
23+
script:
24+
- make test

modules/ecs_fargate/main.tf

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ resource "aws_ecs_task_definition" "this" {
3939

4040
family = var.family
4141

42-
# Fargate incompatible parameter
43-
dynamic "inference_accelerator" {
44-
for_each = var.inference_accelerator != null ? var.inference_accelerator : []
45-
46-
content {
47-
device_name = inference_accelerator.value.device_name
48-
device_type = inference_accelerator.value.device_type
49-
}
50-
}
42+
# Fargate incompatible parameter on v6.0.0
43+
# dynamic "inference_accelerator" {
44+
# for_each = var.inference_accelerator != null ? var.inference_accelerator : []
45+
46+
# content {
47+
# device_name = inference_accelerator.value.device_name
48+
# device_type = inference_accelerator.value.device_type
49+
# }
50+
# }
5151

5252
# Fargate incompatible parameter
5353
ipc_mode = var.ipc_mode

modules/ecs_fargate/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ output "family" {
3535

3636
output "inference_accelerator" {
3737
description = "Inference accelerator settings."
38-
value = aws_ecs_task_definition.this.inference_accelerator
38+
value = null
3939
}
4040

4141
output "ipc_mode" {

smoke_tests/ecs_fargate/all-dd-disabled.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module "dd_task_all_dd_disabled" {
3636
enabled = false,
3737
}
3838

39-
family = "terraform-test-all-dd-disabled"
39+
family = "${var.test_prefix}-all-dd-disabled"
4040
container_definitions = jsonencode([
4141
{
4242
name : "dummy-container",

smoke_tests/ecs_fargate/all-dd-inputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ module "dd_task_all_dd_inputs" {
5757
}
5858

5959
# Configure Task Definition
60-
family = "terraform-test-all-dd-inputs"
60+
family = "${var.test_prefix}-all-dd-inputs"
6161
container_definitions = jsonencode([
6262
{
6363
name = "datadog-dogstatsd-app",

smoke_tests/ecs_fargate/all-ecs-inputs.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
################################################################################
99

1010
resource "aws_efs_file_system" "fs" {
11-
creation_token = "my-efs-file-system"
11+
creation_token = "${var.test_prefix}-efs-file-system"
1212
performance_mode = "generalPurpose"
1313
tags = {
1414
Name = "MyEFSFileSystem"
@@ -32,7 +32,7 @@ resource "aws_efs_access_point" "fs" {
3232
}
3333

3434
resource "aws_iam_role" "ecs_task_role" {
35-
name = "terraform-test-ecs-task-role"
35+
name = "${var.test_prefix}-ecs-task-role"
3636

3737
assume_role_policy = jsonencode({
3838
Version = "2012-10-17"
@@ -49,7 +49,7 @@ resource "aws_iam_role" "ecs_task_role" {
4949
}
5050

5151
resource "aws_iam_policy" "ecs_task_policy" {
52-
name = "terraform-test-ecs-task-policy"
52+
name = "${var.test_prefix}-ecs-task-policy"
5353
description = "Policy for ECS task role to access EFS"
5454
policy = jsonencode({
5555
Version = "2012-10-17"
@@ -82,7 +82,7 @@ module "dd_task_all_ecs_inputs" {
8282
dd_site = var.dd_site
8383
dd_service = var.dd_service
8484

85-
family = "terraform-test-all-ecs-inputs"
85+
family = "${var.test_prefix}-all-ecs-inputs"
8686
container_definitions = jsonencode([
8787
{
8888
name = "datadog-dummy-app",

smoke_tests/ecs_fargate/all-null.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module "dd_task_all_null" {
1313

1414
# Required values
1515
dd_api_key = var.dd_api_key
16-
family = "terraform-test-all-null"
16+
family = "${var.test_prefix}-all-null"
1717
container_definitions = jsonencode([
1818
{
1919
name : "dummy-container",

smoke_tests/ecs_fargate/all-windows.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module "dd_task_all_windows" {
2424
enabled = true
2525
}
2626

27-
family = "terraform-test-all-windows"
27+
family = "${var.test_prefix}-all-windows"
2828
container_definitions = jsonencode([
2929
{
3030
name = "datadog-dogstatsd-app",

smoke_tests/ecs_fargate/apm-dsd-tcp-udp.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module "dd_task_apm_dsd_tcp_udp" {
2828
socket_enabled = false,
2929
}
3030

31-
family = "terraform-test-apm-dsd-tcp-udp"
31+
family = "${var.test_prefix}-apm-dsd-tcp-udp"
3232
container_definitions = jsonencode([
3333
{
3434
name = "datadog-dogstatsd-app",

smoke_tests/ecs_fargate/cws-only.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module "dd_task_cws_only" {
3535
enabled = true,
3636
}
3737

38-
family = "terraform-test-cws-only"
38+
family = "${var.test_prefix}-cws-only"
3939
container_definitions = jsonencode([
4040
{
4141
name = "datadog-cws-app",

0 commit comments

Comments
 (0)