Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: list domains managed on AWS Lightsail #53

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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