Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
dev.zio:zio-aws-amp_2.12
Advanced tools
ZIO AWS is AWS wrapper for ZIO for all AWS services using the AWS Java SDK v2.
The goal is to have access to all AWS functionality for cases when only a simple, direct access is needed from a ZIO application, or to be used as a building block for higher level wrappers around specific services.
Key features of ZIO AWS:
There are tones of artifacts published for each AWS service. We can pick whichever services we need.
The following example uses the ElasticBeanstalk and EC2 APIs:
Note
See the artifacts page for the latest release.
libraryDependencies += "dev.zio" %% "zio-aws-core" % "<version>"
libraryDependencies += "dev.zio" %% "zio-aws-ec2" % "<version>"
libraryDependencies += "dev.zio" %% "zio-aws-elasticbeanstalk" % "<version>"
libraryDependencies += "dev.zio" %% "zio-aws-netty" % "<version>"
And here is the example code:
import zio.aws.core.AwsError
import zio.aws.core.config.AwsConfig
import zio.aws.ec2.Ec2
import zio.aws.ec2.model._
import zio.aws.ec2.model.primitives._
import zio.aws.elasticbeanstalk.ElasticBeanstalk
import zio.aws.elasticbeanstalk.model._
import zio.aws.elasticbeanstalk.model.primitives._
import zio.aws.netty.NettyHttpClient
import zio._
import zio.stream._
object ZIOAWSExample extends ZIOAppDefault {
val program: ZIO[Ec2 & ElasticBeanstalk, AwsError, Unit] =
for {
appsResult <- ElasticBeanstalk.describeApplications(
DescribeApplicationsRequest(applicationNames = Some(List(ApplicationName("my-service"))))
)
app <- appsResult.getApplications.map(_.headOption)
_ <- app match {
case Some(appDescription) =>
for {
applicationName <- appDescription.getApplicationName
_ <- Console
.printLine(
s"Got application description for $applicationName"
)
.ignore
envStream = ElasticBeanstalk.describeEnvironments(
DescribeEnvironmentsRequest(applicationName =
Some(applicationName)
)
)
_ <- envStream.run(ZSink.foreach { env =>
env.getEnvironmentName.flatMap { environmentName =>
(for {
environmentId <- env.getEnvironmentId
_ <- Console
.printLine(
s"Getting the EB resources of $environmentName"
)
.ignore
resourcesResult <-
ElasticBeanstalk.describeEnvironmentResources(
DescribeEnvironmentResourcesRequest(environmentId =
Some(environmentId)
)
)
resources <- resourcesResult.getEnvironmentResources
_ <- Console
.printLine(
s"Getting the EC2 instances in $environmentName"
)
.ignore
instances <- resources.getInstances
instanceIds <- ZIO.foreach(instances)(_.getId)
_ <- Console
.printLine(
s"Instance IDs are ${instanceIds.mkString(", ")}"
)
.ignore
reservationsStream = Ec2.describeInstances(
DescribeInstancesRequest(instanceIds = Some(instanceIds.map(id => zio.aws.ec2.model.primitives.InstanceId(ResourceId.unwrap(id)))))
)
_ <- reservationsStream.run(ZSink.foreach { reservation =>
reservation.getInstances
.flatMap { instances =>
ZIO.foreach(instances) { instance =>
for {
id <- instance.getInstanceId
typ <- instance.getInstanceType
launchTime <- instance.getLaunchTime
_ <- Console.printLine(s" instance $id:").ignore
_ <- Console.printLine(s" type: $typ").ignore
_ <- Console
.printLine(
s" launched at: $launchTime"
)
.ignore
} yield ()
}
}
})
} yield ()).catchAll { error =>
Console
.printLineError(
s"Failed to get info for $environmentName: $error"
)
.ignore
}
}
})
} yield ()
case None =>
ZIO.unit
}
} yield ()
override def run: URIO[ZIOAppArgs, ExitCode] = {
val httpClient = NettyHttpClient.default
val awsConfig = httpClient >>> AwsConfig.default
val aws = awsConfig >>> (Ec2.live ++ ElasticBeanstalk.live)
program
.provideLayer(aws)
.either
.flatMap {
case Left(error) =>
Console.printLineError(s"AWS error: $error").ignore.as(ExitCode.failure)
case Right(_) =>
ZIO.unit.as(ExitCode.success)
}
}
}
Learn more on the ZIO AWS homepage!
For the general guidelines, see ZIO contributor's guide.
See the Code of Conduct
FAQs
Low-level AWS wrapper for ZIO
We found that dev.zio:zio-aws-amp_2.12 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.