Skip to content

Commit

Permalink
Merge pull request #53 from vst/45-list-domains-managed-on-aws-lightsail
Browse files Browse the repository at this point in the history
feat: list domains managed on AWS Lightsail
  • Loading branch information
vst authored May 14, 2024
2 parents d4c8a9e + bf399b7 commit b1d9632
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/Clompse/Programs/ListDomains.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,15 @@ listDomainsForCloudConnection
=> CloudConnection
-> m [Types.Domain]
listDomainsForCloudConnection (CloudConnectionAws conn) = do
eRecords <- runExceptT (Providers.Aws.listDomainsRoute53 conn)
case eRecords of
eRecordsRoute53 <- runExceptT (Providers.Aws.listDomainsRoute53 conn)
recordsRoute53 <- case eRecordsRoute53 of
Left e -> _log (" ERROR (AWS Route53 Domains): " <> Z.Text.tshow e) >> pure []
Right records -> pure records
eRecordsRouteLightsail <- runExceptT (Providers.Aws.listDomainsLightsail conn)
recordsLightsail <- case eRecordsRouteLightsail of
Left e -> _log (" ERROR (AWS Lightsail Domains): " <> Z.Text.tshow e) >> pure []
Right records -> pure records
pure (recordsRoute53 <> recordsLightsail)
listDomainsForCloudConnection (CloudConnectionDo conn) = do
eRecords <- runExceptT (Providers.Do.listDomains conn)
case eRecords of
Expand Down
3 changes: 2 additions & 1 deletion src/Clompse/Providers/Aws.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ module Clompse.Providers.Aws (
AwsConnection (..),
listBucketsLightsail,
listBucketsS3,
listDomainsLightsail,
listDomainsRoute53,
listServersEc2,
listServersLightsail,
) where

import Clompse.Providers.Aws.ApiAws (listBucketsS3, listDomainsRoute53, listServersEc2)
import Clompse.Providers.Aws.ApiLightsail (listBucketsLightsail, listServersLightsail)
import Clompse.Providers.Aws.ApiLightsail (listBucketsLightsail, listDomainsLightsail, listServersLightsail)
import Clompse.Providers.Aws.Connection (AwsConnection (..))
import Clompse.Providers.Aws.Error (AwsError (..))

19 changes: 19 additions & 0 deletions src/Clompse/Providers/Aws/ApiLightsail.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,25 @@ listBucketsLightsail =
awsListAllLightsailBuckets


listDomainsLightsail
:: MonadIO m
=> MonadError AwsError m
=> AwsConnection
-> m [Types.Domain]
listDomainsLightsail cfg = do
env <- _envFromConnection cfg
let prog = Aws.send env Aws.Lightsail.newGetDomains
resIs <- liftIO . fmap (fromMaybe [] . L.view Aws.Lightsail.Lens.getDomainsResponse_domains) . Aws.runResourceT $ prog
pure $ fmap mkTuple resIs
where
mkTuple b =
let name = b L.^. Aws.Lightsail.Lens.domain_name
in Types.Domain
{ Types._domainName = fromMaybe "<unknown-lightsail-domain>" name
, Types._domainProvider = Types.ProviderAws
}


-- * Data Definitions


Expand Down

0 comments on commit b1d9632

Please sign in to comment.