question
stringlengths
11
28.2k
answer
stringlengths
26
27.7k
tag
stringclasses
130 values
question_id
int64
935
78.4M
score
int64
10
5.49k
I am trying to explore features of KeyCloak server and want to get information about access token by using /openid-connect/token/introspect endpoint. So, I am sending next request to this endpoint curl -v --data "token_type_hint=access_token&client_id=product- app&username=user&token=MY ACCESS TOKEN" http://localhost...
It seems like you are not able to use /openid-connect/token/introspect endpoint when your client has public access type. So, switch to the CONFIDENTIAL ACCESS TYPE and use curl -v --data "client_secret=YOUR_SECRET9&client_id=product- app&username=user&token=YOUR_TOKEN" http://localhost:8080/auth/realms/springdemo/pro...
Keycloak
51,132,711
28
I have an application which is getting Auth from Keycloak. My Access Type is public so I do not have any client secret. I have given access to "Direct Access Grants Enabled" as ON Refer below: I am getting error from postman as below: { "error": "invalid_grant", "error_description": "Invalid user credentials" ...
The error message "Invalid user credentials" is reliable. That is, you either specified a wrong username or password. Check that the user really exists in the realm you are addressing with the URL. Particularly if it is not the master realm which usually will be used to login to keycloak admin console.
Keycloak
48,146,410
27
I realized there are many iterations of this questions. But I can't seem to understand the answer correctly. We have secured our rabbitmq and rest endpoints with a oauth2 spring server similar to this post. But it doesn't have all of the features we need and want. So we would like to use Keycloak. I have been succe...
The keys are also directly on https://keycloak-server/auth/realms/my-realm In a format directly exploitable with your code: { "realm": "my-realm", "public_key": "MIIBI...", "token-service": "https://keycloak-server/auth/realms/my-realm/protocol/openid-connect", "account-service": "https://keycloak-serv...
Keycloak
54,318,633
27
I'm trying to run example app from: https://github.com/keycloak/keycloak-quickstarts/tree/latest/app-springboot I'm getting error: *************************** APPLICATION FAILED TO START *************************** Description: Parameter 1 of method setKeycloakSpringBootProperties in org.keycloak.adapters.springboot....
I don't have a solution at the moment, but I can see that the exact same issue has been registered on the Keycloak Jira a couple of months ago: https://issues.jboss.org/browse/KEYCLOAK-10595. The problem seems to be caused by the code delivered with this PR: https://github.com/keycloak/keycloak/pull/6075. The author of...
Keycloak
57,787,768
27
Switched to m1 mac a week ago and I cannot get my application up and running with docker because of the jboss/keycloak image not working as expected. Getting the following message from the container when trying to access localhost:8080 12:08:12,456 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC000001: ...
Also you can build the keycloak docker image locally, I was able to start keycloak after doing that. Here are the steps I follow; Clone Keycloak containers repository: git clone git@github.com:keycloak/keycloak-containers.git Open server directory (cd keycloak-containers/server) Checkout at desired version, eg. git ch...
Keycloak
67,044,893
27
I would like to ask, if somebody knows, why there are no roles within the user details in REST ADMIN API request. I saw some posts dealing with this topic, but there were either no clear answer or they propose to use keycloak-admin-client, but that seems not very convenient. Maybe I need to map the roles in Admin conso...
You are not getting roles in the user details because the REST API is strictly resource based and roles are separate objects that are just associated to a user. The following REST URLs can be used to get a user's roles Getting the associated realm roles: GET /auth/admin/realms/{realm}/users/{user-uuid}/role-mappings/re...
Keycloak
48,458,138
26
I am using the latest keycloak image in docker and can access the standard admin console at http://localhost:9080. However, I cant seem to access any of the paths specified in the documentation for Admin REST api. For instance, the base path /auth and Resource Get clients belonging to the realm Returns a list of client...
I'm almost sure you are trying to call the endpoint like this: http://localhost:9080/auth/admin/realms/demo/clients However, you've missed this part/auth/admin/realms Please, don't forget to authorize your call first as stated here UPDATE Here are my steps to see the results: $ docker run -d -e KEYCLOAK_USER=admin -e...
Keycloak
48,507,224
26
I am trying to setup Keycloak as a IdP (Identity Provider) and Nextcloud as a service. I want to setup Keycloak as to present a SSO (single-sign-on) page. I am running a Linux-Server with a Intel compatible CPU. What is the correct configuration? Keycloak will be running as https://kc.example.com Nextcloud will be run...
Prerequisite: To use this answer you will need to replace example.com with an actual domain you own. Also, replace email@example.com with your working e-mail address. It is assumed you have docker and docker-compose installed and running. Setup your services with Docker In addition to keycloak and nextcloud I use: ngi...
Keycloak
48,400,812
25
I understand that keycloak has built-in clients and we add the users later on. But in general, what is the difference between a client and a user in Keycloak?
According to the Keycloak documentation User - Users are entities that are able to log into your system Client - Clients are entities that can request Keycloak to authenticate a user. Most often, clients are applications and services that want to use Keycloak to secure themselves and provide a single sign-on solutio...
Keycloak
49,107,701
25
Can someone please explain the cookies set by Keycloak: KEYCLOAK_SESSION,Oauth_token_request_state, KEYCLOAK_IDENTITY. What is the relevance of each cookies?
They are cookies for internal use of Keycloak. KEYCLOAK_IDENTITY contains a token (JWT) with the user ids. You can view its content using jwt.io (for example). This cookie lives with your browser session and can also be refreshed with SSO. (for example, if you change some of your personal data in the "Manage my account...
Keycloak
50,589,548
25
I have tried to access the keycloak API from the postman. but it is showing 400 bad request. I was calling api in the below format. http://{hostname}:8080/auth/realms/master/protocol/openid-connect/token?username=admin&password=admin&client_id=admin-cli&grant_type=password In the headers I have set the content_type a...
A bit late for this question, but you did ask about postman and not curl. So you have to put the options in x-www-form-urlencoded
Keycloak
49,313,554
23
How can I get user keycloak attributes (username, firstname, email...) based on user id? The user I'm using in the Keycloak session has already the role view-users assigned so I should be able to list at least all users, is there any Keycloak class that I can use? What I'm trying to achieve here is to avoid to replica...
You can use the Admin REST API. The detailed description of the relevant API is available here. Also you can use the JAVA wrapper API. Please find couple of examples below. Example 1, REST: Get an access token: curl \ -d "client_id=admin-cli" \ -d "username=admin" \ -d "password=secret" \ -d "grant_type=passwor...
Keycloak
55,643,277
23
I'm trying to interact with Keycloak via its REST API. I have the master realm and the default admin user, and a test realm. Firstly, I get an access token for the admin account and test realm: let data = { grant_type : 'password', client_id : 'test-realm', username : 'admin', password : 'admin' }; let ...
I got a 401 error because I generated the offline token by using http://localhost:8080 and then I tried to request the api by using http://keycloak:8080 which is not allowed. Unfortunately the log doesn't tell you that. To debug JWT tokens I recommend https://jwt.io/
Keycloak
46,882,610
22
I want to write unit tests for my spring controller. I'm using keycloak's openid flow to secure my endpoints. In my tests I'm using the @WithMockUser annotation to mock an authenticated user. My problem is that I'm reading the userId from the token of the principal. My unit test now fails because the userId I read from...
@WithmockUser configures the security-context with a UsernamePasswordAuthenticationToken. This can be just fine for most use-cases but when your app relies on another Authentication implementation (like your code does), you have to build or mock an instance of the right type and put it in the test security-context: Sec...
Keycloak
49,144,953
22
We deployed keycloak server 4.6.0.Final for authentication for our web application How can i configure to get server logs? I cannot find any logs from server.log or Audit.log files. Do I need to configure any place to show the keycloak server log details.
When starting the Keycloak instance you can pass an environment variables to set log level for Keycloak. docker run -e KEYCLOAK_LOGLEVEL=DEBUG jboss/keycloak For the Kubernetes Deployment: Add the following env variable to Kuberenetes deployment manifest. keycloak: extraEnv: | - name: KEYCLOAK_LOGLEVEL v...
Keycloak
58,060,682
22
There is a web server running locally, and I want to have Keycloak (on another domain) login page inside the iframe. I tried the following setting in the Keycloak Real Settings > Security Defenses > Headers > Content-Security-Policy frame-src 'self' http://127.0.0.1 http://192.168.1.140 http://localhost *.home-life.hub...
Try to change: frame-ancestors 'self'; to frame-ancestors 'self' http://127.0.0.1 http://192.168.1.140 http://localhost *.home-life.hub http://trex-macbook.home-life.hub localhost; Generally, tweak frame-ancestors CSP configuration.
Keycloak
60,659,225
22
I have secured an enterprise application with Keycloak using standard wildfly based Keycloak adapters. Issue that I am facing is that the rest web services when invoked, needs to know the username that is currently logged in. How do I get the logged in user information from Keycloak? I tried using SecurityContext , Web...
You get all user information from the security context. Example: public class Greeter { @Context SecurityContext sc; @GET @Produces(MediaType.APPLICATION_JSON) public String sayHello() { // this will set the user id as userName String userName = sc.getUserPrincipal().getName(); if (sc.getUserP...
Keycloak
31,864,062
21
I am implementing a custom login page for keycloak (version 2.5), by following this guide. I added my own custom styling, now I am trying to add the Dutch locale. Currently no Dutch locale is provided, so I provided following properties files: themes/mytheme/login/messages/messages_en.properties themes/mytheme/account...
After reading the code, I understood only adding the files is not enough. You need to enable your theme not only for the login theme, but also for the account and email themes: As I only changed the login theme to my own 'custom-theme', the Dutch locale did not show up.
Keycloak
41,855,394
21
I am trying to implement keycloak as an SSO for my company. I have created two realms, realm A and realm B. I want to use same set of users for both realms ie I need give access to users for both realms. Is it possible to do this in Keycloak?
No that's not possible. Users are always realm specific. The only way would be to keep the users in an external store and integrate this external store via federation (UserStorageSpi) into both realms. But then you'll have to do all user management on the external store, as it is the primary source of your user data.
Keycloak
47,121,643
21
Who knows how to obtain the id_token with Keycloak? I have been working with Keycloak in Java (Spring, JEE) and postman. The basics work fine but I need the id_token since there are some claims that they are not present in the access_token but they are present in the id_token. Using the keycloak-core library I could ob...
If you are using keycloak version 3.2.1, then below mail chain will help you. Hi All I am using below curl command    curl -k  https://IP-ADDRESS:8443/auth/realms/Test123/protocol/openid-connect/token -d "grant_type=client_credentials" -d "client_id=SURE_APP" -d "client_secret=ca3c4212-f3e8-43a4-aa14-1011c7601c67" In ...
Keycloak
49,322,417
21
I like to manage keycloak from my own application:create user & clients, display users & client. As this is not a real user but a machine I would like to use a service account with a client credential grant as proposed in How to get Keycloak users via REST without admin account . To realize this I: create a realm in...
Keycloak differentiates between the Scopes/Scope mapping & the roles management. The Scopes tab: you see in the question above only manages the roles that a client is allowed to request. For the client credential grant to work these roles must be assigned to the client in the "Service Account Roles" Tab. So in the end...
Keycloak
52,238,839
21
I create token using http://localhost:8080/auth/realms/{realm_name}/protocol/openid-connect/token endpoint. grant_type=client_credentials client-id: ------------ client-secret: 78296d38-cc82-4010-a817-65c283484e51 Now I want to get users of realm. Then I send request to http://localhost:8080/auth/admin/realms/{realm_na...
The service account associated with your client needs to be allowed to view the realm users. Go to http://localhost:8080/auth/admin/{realm_name}/console/#/realms/{realm_name}/clients Select your client (which must be a confidential client) In the settings tab, switch Service Account Enabled to ON Click on save, the...
Keycloak
66,452,108
21
I have surfed through google without finding any concrete answers or examples, so again trying my luck here (often get lucky). The problem I have a single spring boot RESTful service running behind an apache reverse proxy. This RESTful service is running HTTP only. Say it's running on local ip 172.s port 8080. I have ...
You need to inform keycloak about the location of the reverse proxy. Then in its response it will set location to there instead of its local address. To do that in the latest keycloak set the environment variable KEYCLOAK_FRONTEND_URL to point to the string https://example.com/auth (yes, it needs the whole address. To ...
Keycloak
42,342,367
20
I have been looking through the Keycloak documentation but cannot see how to do this. With Java, I'd like to take a valid userid and password and then generate a token. How can I do this?
--EDIT 2018-08-31-- You can use the Authorization Client Java API. Once you have created an AuthzClient object, you can pass the username and password to the AuthzClient#authorization(username, password) or AuthzClient#obtainAccessToken(username, password) method to authenticate the user and get the access token (and/o...
Keycloak
52,085,735
20
I am trying to achieve fairly simple usecase of role based client application (VueJS multi-page applications) control using the keycloak. As shown in image, I have three different roles and three different clients in single realm. The arrow in the image represents which role can access which client. So my main objecti...
You can do this without extensions. Copy the desired flow (e.g. the browser flow) Create a new sub flow (e.g. for the browser forms) and call it Access By Role and select generic as type. For the new sub flow ensure that CONDITIONAL is selected in the flow overview. For the new sub flow add execution Condition - User ...
Keycloak
57,287,497
20
I'm using Angular 8.0.3 and keycloak 6.0.1 to make the front authentication. Problem I managed to get to the keycloak login page from my application. After logging in with my login details, an error occurs : -localhost/:1 Access to XMLHttpRequest at 'https://localhost:8080/auth/realms/pwe-realm/protocol/openid-connect/...
I wasted half a day on this while developing with Vue.js against a server on localhost. You probably need to set the Web Origins on your Keycloak server for your Keycloak client: Login to the Keycloak admin screen, select the realm pwe-realm and then your client pwe-web. Scroll to the Web Origin settings and type th...
Keycloak
59,018,604
20
The role uma_authorization is apparently created by default in Keycloak. What is this role? Can I safely delete it?
UMA - User-Managed Access. Keycloak docs.
Keycloak
65,941,530
20
Simple question: Why does the following code work... (it returns the access token just fine) curl --data "grant_type=client_credentials&client_id=synchronization_tool&client_secret=8f6a6e73-66ca-4f8f-1234-ab909147f1cf" http://localhost:8080/auth/realms/master/protocol/openid-connect/token And this one doesn't? curl -...
curl -d 'client_id=xxx' -d 'username=xxx' -d 'password=xxx' -d 'grant_type=password' \ 'http://localhost:8080/auth/realms/YOUR_REALM_NAME/protocol/openid-connect/token' | \ python -m json.tool This works for me, and it will give you the access_token and session_token
Keycloak
50,256,433
19
Having a few minor issues with role based authorization with dotnet core 2.2.3 and Keycloak 4.5.0. In Keycloak, I've defined a role of 'tester' and a client role 'developer' with appropriate role mappings for an 'admin' user. After authenticating to Keycloak; if I look at the JWT in jwt.io, I can see the following: { ...
"AspNetCore.Authorization" expects roles in a claim (field) named "roles". And this claim must be an array of string (multivalued). You need to make some configuration on Keycloak side. The 1st alternative: You can change the existing role path. Go to your Keycloak Admin Console > Client Scopes > roles > Mappers > clie...
Keycloak
56,327,794
19
I'm upgrading my Keycloak from 16 to 20. In 16 I could use this screen to add a custom mapper. In 20.0.2 I can't find this form in the admin panel. There is a Client scopes tab for each client, and it has an add button. But it does not allow me to define my custom mapper. I just adds predefined mappers. Where is that ...
IMO the old ui was a bit more intuitive in this regard. With the new one you need to: Go to your Realm Go to Clients and click on your client switch to 'Client Scopes' In the 'Assigned client scope' click on your client-id-dedicated: then you go to the following menu: Click on 'Configure a new Mapper' and then sele...
Keycloak
74,872,231
19
I'm trying to test Keycloak REST API. Instaled the version 2.1.0.Final. I can access the admin through browser with SSL without problems. I'm using the code above: Keycloak keycloakClient = KeycloakBuilder.builder() .serverUrl("https://keycloak.intra.rps.com.br/auth") .realm("testrealm") .username("development") .passw...
I used the dependency to fix this issue <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jackson2-provider</artifactId> <version>3.1.0.Final</version> </dependency>
Keycloak
39,861,900
18
I am trying to access the create a user in the keycloak programmatically. But I am getting 403 as a status code. I am following the below link. https://technology.first8.nl/programmatically-adding-users-in-keycloak/ Can anyone help me? Thanks In advance I have using the following code to create user Keycloak kc = Key...
I faced the same issue. This is how i fixed it. Create a role that has at least a realm-management role of manage-users UI update for server 9.0.2 Go to your client's Scope tab and add the role to your Realm Roles
Keycloak
49,511,606
18
I'am googling for a while in order to find a documentation of all available say "variables" I can use in the various Keycloak templates. by variable I mean all the ${xxx.yyy} things I can use to inject some dynamic values inside the template. Through the documentation I can find here and there some of them (like ${user...
You can look for the template providers in Keycloak's code. All the templates are "ftl" files filled with a map called "attributes". Keycloak has a couple of classes which fill those templates with Beans depending on the page or action as CharlyP mentioned. For example: FreeMarkerEmailTemplateProvider class fills the ...
Keycloak
50,562,384
18
I'm kind of desesperate to make this keycloak work. I can authenticate but for some reason, my token introspection always fail. For example if I try to authenticate: curl -d 'client_id=flask_api' -d 'client_secret=98594477-af85-48d8-9d95-f3aa954e5492' -d 'username=jean@gmail.com' -d 'password=superpassE0' -d 'grant_typ...
You need to make sure that you introspect the token using the same DNS hostname/port as the request. Unfortunately that's a not widely documented "feature" of Keycloak... So use: curl -u "flask_api:98594477-af85-48d8-9d95-f3aa954e5492" -d "token=<token>" http://keycloak.dev.local:9000/auth/realms/skilltrock/protocol...
Keycloak
53,721,588
18
I'm using keycloak to secure my rest API, I followed this tutorial to PROGRAMMATICALLY ADDING USERS, but I get that error message: ERROR [io.undertow.request] (default task-9) UT005023: Exception handling request to /service/secured: org.jboss.resteasy.spi.UnhandledException: javax.ws.rs.client.ResponseProcessingExcep...
The Keycloak Admin Client (starting from version 1.9.0) supports the resteasy-jackson2-provider JSON provider out of the box, and this resolves the issue. Use it in place of resteasy-jackson-provider in your pom.
Keycloak
37,786,756
17
I've seen those two post that give a solution to this question but they do not provide detailed enough informations about how to do it for non Java developer like me: Keycloak add extra claims from database / external source How to register a custom ProtocolMapper in Keycloak? Here is a recap of their solutions that co...
I hope this step by step guide helps you I'm using Keycloak 4.5.0 - because I have this newer version installed - but I should not make a big difference. And I implemented a OIDCProtocolMapper in the example. Just to summarize it - for the quick overview for others - each step is described more detailed later You imp...
Keycloak
53,089,776
17
How to get client secret via Keycloak API? In documentation I see: GET /admin/realms/{realm}/clients/{id}/client-secret My code is the following: data = { "grant_type" : 'password', "client_id" : 'myclientid', "username" : 'myusername', "password" : 'mypassword' } response = requests.get("https://mylin...
You can't get client_secret for public clients. Your client should have 'access_type` = 'confidential' Go to CLIENTS section of your realm admin panel (<protocol>://<host>:<port>/auth/admin/master/console/#/realms/<your realm>/clients/<your client code>) Change Access Type to confidential Press 'SAVE' Go to the "Cred...
Keycloak
53,538,100
17
Hi I'm trying to use the Keycloak API but I don't understand very well how it works. I want to obtain all the users of a realm. So I first obtain a token using this endpoint: /realms/master/protocol/openid-connect/token with this params in the request body: client_id grant_type username password client_secret The fir...
You need two steps first get an access token from the admin-cli client of the master realm second call the admin rest api with the access token, set Bearer as prefix in the Authorization header. # get an access token curl -X POST \ https://<HOST>/auth/realms/master/protocol/openid-connect/token \ -H 'Accept: ap...
Keycloak
55,535,440
17
When a user is created through the Keycloak admin console, is there a way to notify a user via email that a profile has been created and the user can finish registration following by a link? Currently, the user can get an email about profile being created only if after creation a password had been set for the user. And...
I accomplished the same thing by customizing the keycloak theme templates for the emails sent and for the login pages. Here's the Keycloak docs on how to customize the themes. Here's the specifics of how I did it: First, I customized the executeActions.ftl email template to be pretty and say "welcome to our applicati...
Keycloak
57,393,543
17
I am trying to determine if the JwtBearer Service provided for .Net Core 3.0, actually uses the asymettric signing key that is provided by my oidc provider's well known configuration? I can't find any documentation around this. .AddJwtBearer(opt => { opt.Authority = "http://localhost:8180/auth/realms/master"; o...
I was wondering same - research/debugging showed that JwtBearer indeed trying to contact authority to get public key. Here is function called during validation : // System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.cs protected virtual SecurityKey ResolveIssuerSigningKey(string token, JwtSecurityToken jwtToke...
Keycloak
58,758,198
17
I cannot import any realms into Keycloak 18.0.0. That's the Quarkus, and not the Wildfly distribution anymore. Documentation here says it should be pretty simple, and by mounting my exported realm.json file into /opt/keycloak/data/import/...json it actually TRIES to import it, but it ends with : "[org.keycloak.quarkus....
This might be caused because inside of your realm .json there is references to some configuration that is using the deprecated upload script feature. Try to removed it, export the json and them try to imported again (this time without the upload script feature. From the comments (credits to jfrantzius):  See here for ...
Keycloak
72,128,765
17
I am using Keycloak server to implement SSO. I am able to get access token for a specific client using client_credentials flow. However, my observation is that the access token is granted for internal service account of the client. I would like to get access token for other users present in realm by providing some addi...
I think you're misunderstanding some Oauth concepts right here. The client_credentials grant should only be used for a service itself to grant access to an specific resource. Imagine this scenario: End User -> Docs Service -> Docs Repo The end user has access to some docs stored in the repo through the docs service. In...
Keycloak
41,756,879
16
I have single page application that is built using Angularjs and integrated with Keycloak for authentication and authorization. I am able to login into my application, get loggedin user roles etc. goes The moment refresh token call, it always returns in my else case, and user logout of the application. Though the token...
I couldn't find explained it in the API docs but the timeout argument of keycloak.updateToken() function is expressed in seconds, not in minutes. So if the Access Token Lifespan on server is at the default value of 5 minutes, you should use a value less than 300 seconds. I learned it doing some experiments. //Update th...
Keycloak
42,499,818
16
Default port of Keycloak used to be on 8080. Now when I am starting keycloak using ./bin/standalone.sh then it is getting start on 9990 port. // So I guess now keycloak default port is 9990 nowadays. but funny part is whenever I am giving explicit keycloak port like below: ./bin/standalone.sh -Djboss.socket.binding...
I changed the http port of keycloak serve (I'm using 19.0.1 version distribution powered by Quarkus) by doing the following steps : Open : keycloak-folder/conf/keycloak.conf Set the port number : http-port=8180 Note that you can also set the port number at the command line : on Linux/Unix: $ bin/kc.sh start-dev --htt...
Keycloak
47,508,036
16
I connected our active directory to keycloak (4.0.0.Beta1) and imported the users - this works fine. But the username should be filled from sAMAccountName. So i changed the Username LDAP attribute to that. But after clicking Synchronize all users i am getting this error in the console window: 8:20:13,372 ERROR [org.key...
I have just tested it in 4.1.0.Final and there it works when you change the Username LDAP attribute to sAMAccountName and additionally the LDAP Attribute in the username mapper also to sAMAccountName. I tried some mappers (especially username) but with no luck. Your question suggest, that you already tried doing som...
Keycloak
50,168,751
16
Im looking at the new Keycloak Beta 4 API. When i get the users account information, what is referred to as 'id' in the web ui comes back as 'sub' in the account object. { sub: '25a37fd0-d10e-40ca-af6c-821f20e01be8', name: 'Barrack Obama', preferred_username: 'obama@whitehouse.gov', given_name: 'Barrack', famil...
As per the keycloak documentation Anatomy of Action Token Action token is a standard Json Web Token signed with active realm key where the payload contains several fields: typ - Identification of the action (e.g. verify-email) iat and exp - Times of token validity sub - ID of the user azp - Client name iss - Issue...
Keycloak
50,397,205
16
We've decided to move to KeyCloak for our identity and access management solution, rather than implement it entirely within our Java EE web app. We're creating a multi-tenant solution, and would prefer to create security realms/users/groups programmatically through our workflow, rather than leveraging KeyCloak's self-...
I found some info around the KeyCloak Java Admin Client. This gist has lots of useful examples showing how to managed users, realms, etc.
Keycloak
51,521,958
16
I have followed the guide https://ultimatesecurity.pro/post/okta-saml/ , to configure OKTA Saml with keycloak. After this configuration, I see Okta/saml login button on login page, clicking on which, the user is redirected to Okta login/SSO. Now, is there a way to avoid clicking on this button everytime such that when...
The solution is pretty simple. 1. Go to Realm -> Configure -> Authentication 2. Go to Flows -> Browser-> Identity Provider Redirecter -> Actions -> Config 3. Enter the saml / okta identity provider name that you have created for your realm (as you can see in my case it was saml-okta-41)
Keycloak
51,925,423
16
I'm trying to securize an Angular app with a Keycloak server. I've followed some tutorials that give more or less the same instructions in order to do so, but I got stuck with the following error: Timeout when waiting for 3rd party check iframe message. I start my keycloak server using the following docker-compose co...
My solution is set the checkLoginIframe to false. Below is my configuration: keycloak.init({ config: { url: 'http://localhost:10010', realm: 'nerthus', clientId: 'blog' }, initOptions: { pkceMethod: 'S256', // must match to the configured value in keycloak redirectUri: 'http:/...
Keycloak
72,019,588
16
I'm trying to get the key from Keycloak open-id connect certs endpoint that allow me to validate a JWT token. The api to fetch the keys seam to work : GET http://localhost:8080/auth/realms/my-realm/protocol/openid-connect/certs { "keys": [ { "kid": "MfFp7IWWRkFW3Yvhb1eVrtyQQNYqk6BG-6HZFpl_JxI", "kty": "R...
Looking at https://github.com/keycloak/keycloak/blob/master/core/src/main/java/org/keycloak/jose/jwk/JWKParser.java it seams that returned key are pem encoded using : modulus exponent Look at the mentionned java class to get a public key in java or https://github.com/tracker1/node-rsa-pem-from-mod-exp to get the pub...
Keycloak
39,890,232
15
So I want to have single sign in, in all the products using a auth server but that's not only for employees, keycloak should be used to that like auth0?
There are also some advantages to Keycloak: Keycloak is also available with support if you buy JBoss EAP (see http://www.keycloak.org/support.html). This might be cheaper than the enterprise version of Auth0. If you want to use custom DB, you need enterprise version of Auth0 anyway. Keycloak has features which are not ...
Keycloak
46,453,490
15
I am trying to use clustered keycloak docker behind the A10 load balancer. I am trying access all the request by https from the client application. My issue is that the same setup is working when we try to access keycloak has HTTP but at the same time when we try to access this has HTTPS it is not working. Can anyone h...
I know this is an older question, but I couldn't find a satisfying answer anywhere and I wanted to share my solution. This eventually worked for me in an AWS Environment with an Application Load Balancer: Run the keycloak docker container with the environment variable PROXY_ADDRESS_FORWARDING=true As seen in the keyclo...
Keycloak
47,068,266
15
I want to use keycloak to authenticate my users in our Superset environment. Superset is using flask-openid, as implemented in flask-security: http://flask-appbuilder.readthedocs.io/en/latest/_modules/flask_appbuilder/security/manager.html https://pythonhosted.org/Flask-OpenID/ To enable a different user authenticati...
Update 03-02-2020 @s.j.meyer has written an updated guide which works with Superset 0.28.1 and up. I haven't tried it myself, but thanks @nawazxy for confirming this solution works. I managed to solve my own question. The main problem was caused by a wrong assumption I made regarding the flask-openid plugin that super...
Keycloak
47,678,321
15
I have a Spring Boot project with keycloak integrated. Now I want to disable keycloak for testing purposes. I tried by adding keycloak.enabled=false to application.properties as mentioned in Keycloak documentation but it didnt work. So how do I disable it?
Update 2022 Please follow this excellent guide on Baeldung. For anyone who might have the same trouble, here is what I did. I didn't disable Keycloak but I made a separate a Keycloak config file for testing purposes. Here is my config file @Profile("test") @Configuration @EnableWebSecurity public class SecurityTestCon...
Keycloak
47,861,513
15
I'm using keycloak 3.4 and spring boot to develop a web app. I'm using the Active Directory as User Federation to retrieve all users information. But to use those information inside my web app I think I have to save them inside the "local-webapp" database. So after the users are logged, how can I save them inside my da...
In order to access the whole list of users, you must verify that the logged user contains at least the view-users role from the realm-management client, see this answer I wrote some time ago. Once the user has this role, the JWT she retrieves will cointain it. As I can infer from your comments, you seem to lack some ba...
Keycloak
48,583,361
15
I am trying to setup Keycloak server for our organisation. I have couple of questions. How can we use our existing user database to authenticate users - User Federation. Keycloak only has LADP/Kerberos options. Is there any custom plugin which can be used for MySQL user authentication or can we use existing connectors...
Check Keycloak Custom User Federation It means that, to use diffirent datasource (or process) while Keycloak username / password login see => https://github.com/keycloak/keycloak/blob/main/docs/documentation/server_development/topics/user-storage/simple-example.adoc https://tech.smartling.com/migrate-to-keycloak-with-...
Keycloak
50,087,867
15
I am trying to deploy keycloak using docker image (https://hub.docker.com/r/jboss/keycloak/ version 4.5.0-Final) and facing an issue with setting up SSL. According to the docs Keycloak image allows you to specify both a private key and a certificate for serving HTTPS. In that case you need to provide two files: t...
I also faced the issue of getting an ERR_SSL_VERSION_OR_CIPHER_MISMATCH error, using the jboss/keycloak Docker image and free certificates from letsencrypt. Even after considering the advices from the other comments. Now, I have a working (and quite easy) setup, which might also help you. 1) Generate letsencrypt certif...
Keycloak
52,674,979
15
Recently, I hardened my Keycloak deployment to use a dedicated Infinispan cluster as a remote-store for an extra layer of persistence for Keycloak's various caches. The change itself went reasonably well, although after making this change, we started seeing a lot of login errors due to the expired_code error message: ...
I will try to clarify some points to take in mind when you configure Keycloak in cluster. Talking about subject of "infinite redirects", I have experienced a similar problem in development environments years ago. While the keycloak team has corrected several bugs related to infinite loops (e.g. KEYCLOAK-5856, KEYCLOAK-...
Keycloak
57,467,224
15
In Keycloak, by default, users are able to change their first and last name in the account manager page. However, is it possible to disable this behavior? Removing both fields in the theme results in those values not being sent and the form failing, and a hand-crafted POST request would defeat this method anyway.
I came across a similar problem and after reading this SO post, came to know that although you can disable/hide fields in ftl, you cannot disable form validation For e.g I hid firstname field , but still cannot submit. Same was the result with disable as well: I am not aware about disabling a particular field in som...
Keycloak
57,528,936
15
I have a Keycloak server running in an EKS cluster that I'm trying to configure for production instead of dev mode. I've managed to get SSL working with a reverse proxy, but when I go to the login page for the admin console it just loads indefinitely. Here's my configuration: Dockerfile FROM --platform=linux/arm64 qua...
Found the issue. I had to move the ENV KC_PROXY=edge variable in the Dockerfile after running the build script.
Keycloak
73,883,728
15
We're currently evaluating Keycloak as our SSO solution and while it works for our servlet-based applications there's a question regarding our (React-based) SPAs. What our designers want: as an example let's say we have an email client spa. The user is in the process of writing an email but then gets distracted. When h...
For someone who comes back to this question, I think it's better to stick to the best practice for oAuth2/OpenId Connect for SPAs which is currently "Authorization Code Flow" with PKCE. https://oauth.net/2/pkce/ https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics-13 A normal flow here needs a complet...
Keycloak
44,028,912
14
I'm working on a multi tenant project where usernames are actually their email addresses and the domain of the email serves as a tenant identifier. Now in keycloak I'll have different realms per tenant, but I want to have a single login page for all tenants and the actual realm that will do the authentication to be som...
I think Michał Łazowik's answer is on the right track, but for Single-Sign-On to work, it needs to be extended a little. Keep in mind that because of KEYCLOAK-4593 if we have > 100 realms we may have to have multiple Keycloak servers also. We'll need: A separate HTTP server specifically for this purpose, auth-redirect...
Keycloak
44,583,833
14
I'm trying to export a realm file into keycloak docker container, I'm not able to do that because the server is runing when I execute this command: bin/standalone.sh -Dkeycloak.migration.action=export -Dkeycloak.migration.provider=dir -Dkeycloak.migration.dir=<DIR TO EXPORT TO> I tried to modify the docker-entrypoint....
You can start a temporary container. I'm using swarm and attachable network, but replacing the --network flag with some --link to the DB container should do it for a vanilla docker container : docker run --rm --network=naq\ --name keycloak_exporter\ -v /tmp:/tmp/keycloak-export\ -e POSTGRES_DATABASE=keycloa...
Keycloak
49,075,205
14
I'm using Spring Boot (v1.5.10.RELEASE) to create a backend for an application written in Angular. The back is secured using spring security + keycloak. Now I'm adding a websocket, using STOMP over SockJS, and wanted to secure it. I'm trying to follow the docs at Websocket Token Authentication, and it shows the followi...
I was able to enable token based authentication, following the recomendations by Raman on this question. Here's the final code to make it work: 1) First, create a class that represent the JWS auth token: public class JWSAuthenticationToken extends AbstractAuthenticationToken implements Authentication { private stati...
Keycloak
50,573,461
14
We have developed a REST API using the resteasy. (deployed in wildfly 10) Basically these REST APIs are called internally from another application and end points are secured with keycloak. But one endpoint is exposed to outside party (that endpoint is also secured with keycloak). But since the outside party can't prov...
Have you tried to change the order of the elements in the web.xml (eg put filter definitions BEFORE servlet definitions) ? Not sure it will works, but the doc says: "The order of the filters in the chain is the same as the order that filter mappings appear in the web application deployment descriptor" The principle may...
Keycloak
51,387,730
14
Is it necessary to have a keycloak.json file even if we have configured everything in application.properties for a spring boot application.
If you are using Spring Security Adapter, add bean KeycloakConfigResolver in your configuration file. It will use application.properties instead of WEB-INF/keycloack.json @Bean public KeycloakConfigResolver KeycloakConfigResolver() { return new KeycloakSpringBootConfigResolver(); } See: https://developers....
Keycloak
53,533,088
14
I am using keycloak as an identity broker to SAML identity provider in order to login to web application. To get it work I have created new authentication flow which looks like: "Create User If Unique", "Automatically Link Brokered Account". Keycloak redirects correctly to the identity provider with the login page. Aft...
Unfortunately, it is currently not possible to skip the creation of local user account. According to the Keycloak team, they are deferring the support "as we are planning on some larger work to the storage layer which will make it possible to deliver on this capabiltiy". See Feature Request https://issues.jboss.org/bro...
Keycloak
56,492,501
14
Consider the following environment: one docker container is keycloak another docker container is our web app that uses keycloak for authentication The web app is a Spring Boot application with "keycloak-spring-boot-starter" applied. In application.properties: keycloak.auth-server-url = http://localhost:8028/auth A ...
There used to be another property auth-server-url-for-backend-requests but was removed by pull request #2506 as a solution to issue #2623 on Keycloak's JIRA. In the description of this issue, you'll find the reasons why and possible workarounds: that should be solved at the DNS level or by adding entries to the host fi...
Keycloak
57,213,611
14
I run keycloak standalone using a command for docker docker run -p 8080:8080 -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin quay.io/keycloak/keycloak:15.0.2 How to mount a volume to save the data, after container is stopped?
working docker-compose.yml version: "3.7" volumes: keycloak: services: keycloak: image: quay.io/keycloak/keycloak:18.0.2 ports: - 8080:8080 environment: - KEYCLOAK_ADMIN=admin - KEYCLOAK_ADMIN_PASSWORD=admin volumes: - keycloak:/opt/keycloak/data/ restart: always c...
Keycloak
69,812,281
14
Have springboot project in which wanted to either exclude snakeyaml 1.30 or upgrade it 1.31 inorder to avoid fortify issue reporting with snakeyaml 1.30 version there is security vulnerability <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> ...
SnakeYAML is a managed dependency in Spring Boot, so you can simply add the following to the properties section of pom.xml to have Spring Boot 2.3.7 use SnakeYAML 1.31 instead of 1.30: <snakeyaml.version>1.31</snakeyaml.version>
Snyk
73,707,768
22
When trying to figure out how to configure a aws_instance with AWS VPC the following errors occur: * Error launching source instance: InvalidParameterCombination: The parameter groupName cannot be used with the parameter subnet status code: 400, request id: [] or * Error launching source instance: InvalidParameter...
This is due to how a security group is associated with an instance. Without a subnet it is OK to associate it using the security group's name: resource "aws_instance" "server" { ... security_groups = [ "${aws_security_group.my_security_group.name}" ] } In the case where a subnet is also associated you cannot use t...
Terraform
31,569,910
17
I have a list of objects from a variable in terraform variable "persons" { type = list(object({ name = string, phonenumber = string, tshirtSize = string })) description = "List of person" } Now I want a list of the person's names so I can use it to define an AWS Resource How can I convert this obje...
Updated Answer: Use the splat expression var.persons[*].name https://developer.hashicorp.com/terraform/language/expressions/splat Original Answer: I was able to do this in locals file locals { names = [ for person in var.persons: person.name ] } For additional reading SEE: https://www.hashicorp.com/blog/h...
Terraform
62,836,424
17
Question and details How can I allow a Kubernetes cluster in Azure to talk to an Azure Container Registry via terraform? I want to load custom images from my Azure Container Registry. Unfortunately, I encounter a permissions error at the point where Kubernetes is supposed to download the image from the ACR. What I hav...
(I did up the answer above) Just adding a simpler way where you don't need to create a service principal for anyone else that might need it. resource "azurerm_kubernetes_cluster" "kubweb" { name = local.cluster_web location = local.rgloc resource_group_name = local.rgname dns_prefix ...
Terraform
59,978,060
17
I've saved terraform plan -out=my-plan and intend to save it to source control and inject further to custom tool for ingestion and performing testing etc. However, the file contents of my-plan are jumbled and I'm wondering what the encoding used is. What is the encoding being used for the Terraform plan file?
While the other tools mentioned here are useful, things change regularly in the Terraform space and third-party tools often aren't able to be kept up-to-date. For some time now Terraform has directly supported viewing a plan file in the same human-readable format that is displayed at the time you run plan: terraform sh...
Terraform
49,385,346
17
Use Case Trying to provision a (Docker Swarm or Consul) cluster where initializing the cluster first occurs on one node, which generates some token, which then needs to be used by other nodes joining the cluster. Key thing being that nodes 1 and 2 shouldn't attempt to join the cluster until the join key has been genera...
You can redirect the outputs to a file: resource "null_resource" "shell" { provisioner "local-exec" { command = "uptime 2>stderr >stdout; echo $? >exitstatus" } } and then read the stdout, stderr and exitstatus files with local_file The problem is that if the files disappear, then terraform apply will fail. I...
Terraform
44,509,997
17
Is terraform destroy needed before terraform apply? If not, what is a workflow you follow when updating existing infrastructure and how do you decide if destroy is needed?
That would be pretty non-standard, in my opinion. Terraform destroy is only used in cases where you want to completely wipe your infrastructure. One of the biggest features of terraform is that it can do an intelligent delta of your desired infrastructure and your existing infrastructure and only make the changes neede...
Terraform
37,464,875
17
I'm new to Terraform world. I'm trying to run a shell script using Terraform. Below is the main.tf file #Executing shell script via Null Resource resource "null_resource" "install_istio" { provisioner "local-exec" { command = <<EOT "chmod +x install-istio.sh" "./install-istio.sh" EOT interpret...
I think there are two separate things going on here which are actually not related. The main problem here is in how you've written your local-exec script: command = <<EOT "chmod +x install-istio.sh" "./install-istio.sh" EOT This will become the following shell script to run: "chmod +x install-istio...
Terraform
67,297,188
16
Used ami-0fd3c3c68a2a8066f from ap-south-1 region http://cloud-images.ubuntu.com/locator/ec2/, but unable to use t2.micro instance type against this. Error: Error launching source instance: InvalidParameterValue: The architecture 'x86_64' of the specified instance type does not match the architecture 'arm64' of the spe...
Using AWS CLI you can use describe-instance-types: aws ec2 describe-instance-types --filters Name=processor-info.supported-architecture,Values=arm64 --query "InstanceTypes[*].InstanceType" --output text E.g. output: r6gd.large m6g.metal m6gd.medium c6gd.metal m6gd.12xlarge c6g.16xlarge r6g.large r6gd.medium...
Terraform
67,276,619
16
I want to create a map like this: variable "test" { type = map(any) default = { param1 = "sdfsdf", param2 = "sdfsfd", param3 = { mylist = [ "aaaaa", "bbbbb", "ccccc" ] } I get this error: This default value is not compatible with the variable's type constraint: a...
What you've encountered here is the difference in the Terraform language between collection types and structural types. "Map" is a collection type kind, and a map value is any number of elements each identified by an arbitrary string but all values of the same type. In your case it sounds like you want to declare that ...
Terraform
63,180,277
16
I have just run Terraform upgrade. My code was updated but now it shows some errors. The first was: variable "s3_bucket_name" { type = list(string) default = [ "some_bucket_name", "other_bucket_name", ... ] } It doesn't like list(string). I went back to square one and redid the entire Getting Star...
This error appears when you execute terraform 0.12upgrade and your code syntax is already in Terraform 0.12x or obviously a mix of syntax versions <= 0.11x and 0.12x. Also the Unknown token IDENT error can happen when your installed version on your local machine (or in the remote CI/CD server) is 0.11x and your code sy...
Terraform
59,471,513
16
I'm writing the terraform for creating an IAM role for AWS StepFunctions. What should be the value for Principal in assume_role_policy { "Version": "2012-10-17", "Statement": [ { "Action": "sts:AssumeRole", "Principal": { "Service": "stepfunctions.amazonaws.com" }, "Effect": "...
The AWS documentation for service endpoints should hold the answer. Looks like it is states.<region>.amazonaws.com
Terraform
58,762,133
16
I have set up an automation through github/jenkins to post the output of terraform plan for the repo through jenkins as a comment to the pull request in github. The entire orchestration works great except for the fact that the output of terraform plan is not that human readable and doesn't provide you in this kind of a...
By default Terraform uses terminal escape sequences to highlight parts of the output with simple formatting such as colors or a bold typeface. In order to reproduce that result exactly in the context of GitHub would require translating the terminal escape sequences into a form that GitHub is able to render. Unfortunate...
Terraform
58,757,379
16
Is it still not possible to use variable provider in Terraform v0.12.6 ? In *.tfvars I have list variable supplier supplier = ["azurerm.core-prod","azurerm.core-nonprod"] and providers defined in provider.tf: provider "azurerm" { ... alias = "core-prod" } provider "azurerm" { ... alias = "core-nonp...
It is not possible to dynamically associate a resource with a provider. Similar to how in statically-typed programming languages you typically can't dynamically switch a particular symbol to refer to a different library at runtime, Terraform needs to bind resource blocks to provider configurations before expression eva...
Terraform
57,512,884
16
I have the following terraform script which creates an API gateway that passes requests to a lambda function. provider "aws" { access_key = "${var.access_key}" secret_key = "${var.secret_key}" # region = "${var.region}" version = "~> 2.6" } resource "aws_api_gateway_rest_api" "MyDemoAPI" { name ...
Because API Gateway is a complex AWS component and you can control pretty much everything on it (basically every single part of it is managed independently, giving you a lot of control over what you create but also making things harder to deal with). See that it says "Select an Integration Response", but since your Ter...
Terraform
56,071,536
16
I am trying to create an AWS lambda Function using terraform. My terraform directory looks like terraform iam-policies main.tf lambda files/ main.tf main.tf I have my lambda function stored inside /terraform/lambda/files/lambda_function.py. Whenever I terraform apply, I have a "null_resource" that executes ...
Instead of using null_resource, I used the archive_file data source that creates the zip file automatically if new changes are detected. Next I took a reference from the archive_file data in the lambda resource source_code_hash attribute. archive_file data source data "archive_file" "lambda_zip" { type = "zip"...
Terraform
53,849,288
16
What is the Google Cloud Platform mechanism for locking state file when using Terraform? Something like DynamoDB on AWS... thanks
gcs backend implements Terraform state locking by using a special lock file with .tflock extension. This file is placed next to the Terraform state itself for the period of Terraform state operation. For example, if the state file is located at path gs://BUCKET/PREFIX/WORKSPACE.tfstate then the corresponding lock file...
Terraform
53,413,639
16
Working on a Terraform project in which I am creating an RDS cluster by grabbing and using the most recent production db snapshot: # Get latest snapshot from production DB data "aws_db_snapshot" "db_snapshot" { most_recent = true db_instance_identifier = "${var.db_instance_to_clone}" } #Create RDS instance fro...
Try placing an ignore_changes lifecycle block within your aws_db_instance definition: lifecycle { ignore_changes = [ snapshot_identifier, ] } This will cause Terraform to only look for changes to the database's snapshot_identifier upon initial creation. If the database already exists, Terraform will igno...
Terraform
51,486,890
16
When I used aws_cloudwatch_log_resource_policy in a configuration file, it was succesfully applied. I was expecting a policy to appear in IAM -> Policies list in the web console, but there was no sign of new policies. What kind of resource does aws_cloudwatch_log_resource_policy create?
Short answer: it creates a CloudWatch Logs Resource Policy! Long answer: it's a misnomer from AWS as it doesn't actually get attached to a resource at all and appears to be a service-level access policy for CloudWatch logs. The only reference to it I can find in the AWS docs (as of this writing) are the API call and CL...
Terraform
48,912,529
16
It seems like I can use either user_data with a template file or a "remote-exec" provisioner with inline commands to bootstrap. So which one is considered more idiomatic?
You should use user_data. The user data field is idiomatic because it's native to AWS, whereas the remote-exec provisioner is specific to Terraform, which is just one of many ways to call the AWS API. Also, the user-data is viewable in the AWS console, and often an important part of using Auto Scaling Groups in AWS, wh...
Terraform
44,378,064
16
I am attempting to create a Route53 entry for a MySQL RDS instance but having issues with the :3306 at the end of the RDS endpoint returned from Terraform. resource "aws_db_instance" "mydb" { allocated_storage = 10 engine = "mysql" engine_version = "5.6.17" instance_class ...
As well as an endpoint output, Terraform's aws_db_instance resource also outputs address that provides the FQDN of the instance. So all you need to do is change your aws_route53_record resource to use address instead: resource "aws_db_instance" "mydb" { allocated_storage = 10 engine = "mysql" eng...
Terraform
39,855,872
16
I come from a background in Kubernetes and I'm trying to learn AWS/ECS. In Kubernetes, you can use ConfigMap resources to mount simple one-off config files onto containers quickly and easily without having to go through all the trouble of setting up volumes. This also makes it very easy to configure services from Terra...
I've found a "best" solution, and fwiw - this problem vexed me for a year. FIRST - there already an open feature request on the aws/containers-roadmap here: https://github.com/aws/containers-roadmap/issues/56 Please go to that github issue to show support. ECS could make this so much more idiomatic, easier, and intuiti...
Terraform
71,699,327
15
With the following I can loop through a resource block to add route table associations to "all" of my subnets easily. However I need to create associations only for my public subnets. How can I make this "if" statement work? Or any other way to filter on each.value.class == "pub" for that matter. resource "aws_route_...
It depends on exactly what is the structure of your local.subnets_map. But the for_each should be something like the following one: resource "aws_route_table_association" "rtb-pub" { for_each = {for key, val in local.subnets_map: key => val if val.class == "pub"} route_table_id = aws_route_table....
Terraform
66,701,429
15
The idea is that I want to use Terraform resource aws_secretsmanager_secret to create only three secrets (not workspace-specified secret), one for the dev environment, one for preprod and the third one for production env. Something like: resource "aws_secretsmanager_secret" "dev_secret" { name = "example-secret-dev" ...
You could have Terraform generate random secret values for you using: data "aws_secretsmanager_random_password" "dev_password" { password_length = 16 } Then create the secret metadata using: resource "aws_secretsmanager_secret" "dev_secret" { name = "dev-secret" recovery_window_in_days = 7...
Terraform
66,670,949
15
I'm trying to deploy a beanstalk and use this as part of the aws_elastic_beanstalk_environment terraform resource: setting { namespace = "aws:elb:policies:PublicKey" name = "PublicKey" value = var.PUBLICKEY The value of the var.PUBLICKEY should be in this format: -----BEGIN PUBLIC KEY----- sajld...
Although the answer for this case was to make it a single-line string, the question here seems likely to attract searches for multi-line strings in Terraform variables in general, so this answer is for anyone who ends up here in a situation where you can't just make it a single-line string. When setting variables withi...
Terraform
66,609,641
15
I want a stage in an Azure DevOps pipeline to be executed depending on the content of a variable set in a previous stage. Here is my pipeline: stages: - stage: plan_dev jobs: - job: terraform_plan_dev steps: - bash: echo '##vso[task.setvariable variable=terraform_plan_exitcode;isOutput=true]2' ...
I have seen this same issue. You need to use the dependencies variable instead of the stageDependencies: stages: - stage: plan_dev jobs: - job: terraform_plan_dev steps: - bash: echo '##vso[task.setvariable variable=terraform_plan_exitcode;isOutput=true]2' name: terraform_plan - stage: apply_dev dependsOn: pla...
Terraform
65,219,176
15
I have the following folder structure: infrastructure └───security-groups │ │ main.tf │ │ config.tf │ │. security_groups.tf │ └───instances │ main.tf │ config.tf │ instances.tf I would like to reference the security group id instantiated in security-groups folder by reference. I have tr...
To refer to an existing resource you need to use a data block. You won't refer directly to the resource block in the other folder, but instead specify a name or ID or whatever other unique identifier it has. So for a security group, you would add something like data "aws_security_group" "sg" { name = "the-security-gr...
Terraform
64,094,992
15
I have maps of variables like this: users.tfvars users = { "testterform" = { path = "/" force_destroy = true email_address = "testterform@example.com" group_memberships = [ "test1" ] tags = { department : "test" } ssh_public_key = "ssh-rsa AAAAB3NzaC1yc2EAAA4l7" } "testterform2" ...
It sounds like what you need here is a derived "users that have non-empty SSH keys" map. You can use the if clause of a for expression to derive a new collection from an existing one while filtering out some of the elements: resource "aws_iam_user_ssh_key" "this" { for_each = { for name, user in var.users : name ...
Terraform
63,620,298
15
I am trying to run a python function on an AWS Lambda layer, I don't find any documentation on terraform to use an AWS provided lambda layer. How do I use AWS Provided lambda layer AWSLambda-Python27-SciPy1x and runtime Python 2.7? #----compute/lambda.tf---- data "archive_file" "lambda_zip" { type = "zip"...
You have to specify lambda layers as ARNs in terraform using layers parameter: layers - (Optional) List of Lambda Layer Version ARNs (maximum of 5) to attach to your Lambda Function. Using the following syntax in terraform: layers = ["layer-arn"] For example, the ARN for AWSLambda-Python27-SciPy1x in us-east-1 reg...
Terraform
61,927,400
15
I need to create a trigger for an S3 bucket. We use the following to create the trigger: resource "aws_s3_bucket_notification" "bucket_notification" { bucket = var.aws_s3_bucket_id lambda_function { lambda_function_arn = var.lambda_function_arn events = ["s3:ObjectCreated:Put"] filter_pref...
The aws_s3_bucket_notification resource documentation mentions this at the top: NOTE: S3 Buckets only support a single notification configuration. Declaring multiple aws_s3_bucket_notification resources to the same S3 Bucket will cause a perpetual difference in configuration. See the example "Trigger multiple Lambda f...
Terraform
60,502,686
15
I am using, terraform & kubectl to deploy insfra-structure and application. Since I changed aws configure : terraform init terraform apply I always got : terraform apply Error: error validating provider credentials: error calling sts:GetCallerIdentity: InvalidClientTokenId: The security token included in the reque...
From here. This is a general error that can be cause by a few reasons. Some examples: 1) Invalid credentials passed as environment variables or in ~/.aws/credentials. Solution: Remove old profiles / credentials and clean all your environment vars: for var in AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN ...
Terraform
57,865,825
15