diff --git a/.scalafmt.conf b/.scalafmt.conf index 1d053716..e56579f3 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -9,4 +9,6 @@ align.openParenCallSite = false align.openParenDefnSite = false align.tokens = [{code = "=>", owner = "Case"}, "<-", "%", "%%", "="] indent.defnSite = 2 -maxColumn = 120 +maxColumn = 140 + +rewrite.scala3.insertEndMarkerMinLines = 40 \ No newline at end of file diff --git a/examples/aws-webserver/Main.scala b/examples/aws-webserver/Main.scala index 5cb6370e..6d22acf7 100644 --- a/examples/aws-webserver/Main.scala +++ b/examples/aws-webserver/Main.scala @@ -7,6 +7,20 @@ import besom.api.tls val myIp = getExternalIp val port = 80 + // Get the id for the latest Amazon Linux AMI + val ami = ec2.getAmi( + ec2.GetAmiArgs( + filters = List( + GetAmiFilterArgs( + name = "name", + values = List("amzn2-ami-hvm-*-x86_64-ebs") + ) + ), + owners = List("137112412989"), // Amazon + mostRecent = true + ) + ) + // Create a new security group for port 80. val securityGroup = ec2.SecurityGroup( "web-secgrp", @@ -71,14 +85,14 @@ import besom.api.tls |rpm --import https://yum.corretto.aws/corretto.key |yum install -y java-21-amazon-corretto-devel |echo "Hello, World!" > /srv/index.html - |nohup jwebserver -d /srv -b 0.0.0.0 -p $port & + |nohup /usr/lib/jvm/java-21-amazon-corretto/bin/jwebserver -d /srv -b 0.0.0.0 -p $port & |""".stripMargin // Create a server instance val server = ec2.Instance( "web-server-www", ec2.InstanceArgs( - ami = "ami-01342111f883d5e4e", + ami = ami.id, instanceType = ec2.enums.InstanceType.T2_Micro.value, // t2.micro is available in the AWS free tier vpcSecurityGroupIds = List(securityGroup.id), // reference the group object above keyName = keyPair.keyName, @@ -91,14 +105,17 @@ import besom.api.tls server: ec2.Instance <- server _ <- sshKey _ <- keyPair - _ <- p"Connect to SSH the first time: pulumi stack output privateKey --show-secrets > key_rsa && chmod 400 key_rsa && ssh -i key_rsa ${userName}@${server.publicIp}".map(log.info(_)) - _ <- log.info("Connect to SSH: ssh -i key_rsa ec2-user@$(pulumi stack output publicIp)") - _ <- log.info("Connect to HTTP: open http://$(pulumi stack output publicHostName)") + _ <- + p"Connect to SSH the first time: pulumi stack output privateKey --show-secrets > key_rsa && chmod 400 key_rsa && ssh -i key_rsa ${userName}@${server.publicIp}" + .flatMap(log.info(_)) + _ <- log.info("Connect to SSH: ssh -i key_rsa ec2-user@$(pulumi stack output publicIp)") + _ <- log.info("Connect to HTTP: open http://$(pulumi stack output publicHostName)") } yield Pulumi.exports( publicKey = publicKey, privateKey = privateKey, publicIp = server.publicIp, publicHostName = server.publicDns, + ami = ami.id ) } diff --git a/examples/aws-webserver/project.scala b/examples/aws-webserver/project.scala index 289d35c2..ab1f5dc6 100644 --- a/examples/aws-webserver/project.scala +++ b/examples/aws-webserver/project.scala @@ -1,6 +1,6 @@ -//> using scala "3.3.1" -//> using plugin "org.virtuslab::besom-compiler-plugin:0.1.0" -//> using dep "org.virtuslab::besom-core:0.1.0" -//> using dep "org.virtuslab::besom-aws:6.2.1-core.0.1.0" -//> using dep "org.virtuslab::besom-tls:4.11.0-core.0.1.0" +//> using scala 3.3.1 //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement +//> using plugin org.virtuslab::besom-compiler-plugin:0.1.0 +//> using dep org.virtuslab::besom-core:0.1.1-SNAPSHOT +//> using dep org.virtuslab::besom-aws:6.12.0-core.0.1.1-SNAPSHOT +//> using dep org.virtuslab::besom-tls:4.11.0-core.0.1.1-SNAPSHOT diff --git a/integration-tests/CoreTests.test.scala b/integration-tests/CoreTests.test.scala index b192533e..2c055ceb 100644 --- a/integration-tests/CoreTests.test.scala +++ b/integration-tests/CoreTests.test.scala @@ -17,6 +17,7 @@ class CoreTests extends munit.FunSuite { val result = pulumi.up(ctx.stackName).call(cwd = ctx.testDir, env = ctx.env) val output = result.out.text() assert(output.contains("Nothing here yet. It's waiting for you!"), s"Output:\n$output\n") + assert(output.contains("Interpolated value"), s"Output:\n$output\n") assert(result.exitCode == 0) } diff --git a/integration-tests/resources/logger-example/Main.scala b/integration-tests/resources/logger-example/Main.scala index a8f6ccd5..6b82f9fc 100644 --- a/integration-tests/resources/logger-example/Main.scala +++ b/integration-tests/resources/logger-example/Main.scala @@ -3,5 +3,6 @@ import besom.* @main def run = Pulumi.run { for _ <- log.warn("Nothing here yet. It's waiting for you!") + _ <- p"Interpolated ${Output("value")}".flatMap(log.info(_)) yield exports() } \ No newline at end of file